网站导航:首页 -> 思科认证 -> 思科CCIE复习资料 -> CISCO中IP访问控制列表

CISCO中IP访问控制列表

 本实验对ip访问控制列表进行配置和监测,包括标准、扩展和命名的ip访问控制列表。
 1.实验目的
 通过本实验,读者可以掌握以下技能:
 ●配置标准ip访问控制列表;
 ●配置扩展ip访问控制列表;
 ●配置命名的标准ip访问控制列表;
 ●配置命名的扩展ip访问控制列表;
 ●在网络接口上引用ip访问控制列表;
 ●在vty上引用ip访问控制列表;
 ●查看和监测ip访问控制列表。
 2.设备需求
 本实验需要以下设备:
 ●cisco路由器3台,分别命名为r1、r2和r3。要求r1具有1个以太网接口,r2具有1个以太网接口和1个串行接口,r3具有1个串行接口;
 ●1条交叉线序的双绞线,或2条正常线序双绞线和1个hub;
 ●1条dce电缆和1条dte电缆,或1条dce转dte电缆;
 ●1台终端服务器,如cisco 2509路由器,及用于反问telnet的相应电缆;
 ●1台带有超级终端程序的pc机,以及console电缆及转接器。
 3.拓扑结构及配置说明
 本实验拓扑结构如图10-1所示,r1的e0接口与r2的e0接口通过以太网连接起来,r2的s0接口与r3的s0接口通过串行电缆连接起来。
 各路由器相关接口的ip地址分配如图10-1中的标注。
 

 4.实验配置及监测结果
 首先配置各路由器,并且通过路由选择协议的配置实现了整个拓扑的ip连通性,在此基础上进行ip访问控制列表的配置和监测。
 在r1上设置enable口令为cisco,vty口令为ciscol,用于telnet测试。
 以上配置在以前章节中已进行过实验,在本实验中不再给出配置清单。
 我们主要在r2路由器上配置访问控制列表,r1和r3用于测试目的。
 第1部分:配置和引用标准ip访问控制列表
 配置清单10-1列出了在r2路由器上配置和引用标准ip访问控制列表的操作。
 配置清单10-1 配置和引用标准ip访问控制列表
 r2#conf t
 enter configuration commands, one per line. end with cntl/z.
 r2(config)#access-list 1 deny 30.1.1.0 0.0.0.255
 r2(config)#access-ust 1 permit any
 r2(config)#int s0
 r2(config-if)#ip access-group 1 in
 r2(config-if)#^z
 r2#sh
 14:34:20: %sys-5-config_1: configured from console by console
 r2#sh ip access-list 1
 standard ip access list 1
 deny 30.1.1.0,wukdcard buts 0.0.0.255 check=2
 permit any(2 matches)
 r2#sh ip int s0
 serial0 is up, line protocol is up
 internet address is 20.1.1.2/24
 broadcast address is 255.255.255.255
 address determined by setup command
 mtu is 1500 bytes
 helper address is not set
 directed broadcast forwarding is disabled
 multicast reserved groups joined: 224.0.0.9
 outgoing access list is not set
 inbound access list is 1
 proxy arp is enabled
 security level is default
 ... (输出省略)
 r2#clear access-list counters
 r2#sh ip access-1 1
 standard ip access list 1
 deny 30.1 .ia wildcard bits 0.0.0.255
 permit any
 r2#
 term_server#3
 [resuming connection 3 to r3 ... ]
 r3#ping 10.1.1.1
 type escape sequence to abort.
 sending 5, 100-byte icmp echosto 10.1.1.1, timeout is 2 seconds:
 !!!!!
 success rate is 100 percent (5/5). round-tri/min/avg/max=:32/37/48 ms
 r3#ping
 protocol [ip]:
 target ip address: 10.1.1.1
 repeat count [5]:
 datagram size [100]:
 timeout in seconds [2]:
 extended commands [n]: y
 source address or interface: 30.1.1.3
 type of service [0]:
 set df bit in ip header? [no]:
 validate reply data? [no]:
 data pattern [0xabcd]:
 loose, strict, record, timestamp, verbose[none]:
 sweep range of sizes [n]:
 type escape sequence to abort.
 sending 5,100-byte icmp echos to 10.1.1.1,timeout is 2 seconds:
 u.u.u
 success rate is 0 percent (0/5)
 r3#^z
 term_server#2
 [resuming connection 3 to r2 ... ]
 r2#sh ip access-1 1
 standard ip access list 1
 deny 30.1.1.0, wildcard bits 0.0.0.255 (5 matches) checks 15
 permit any (5 matches)
 (1)在定义访问控制列表时,要特别注意语句输入的先后顺序,因为路由器在执行该列表时的顺序是自上而下的。
 另一个应注意的问题是路由器不对由自身产生的ip进行过滤,在实验时应由其他的设备发包进行测试。
 (2)配置标准ip访问控制列表1时,定义了除30.1.1.0/24网段外的所有网段都被接受。
 (3)在r2路由器s0接口的进入方向引用了访问控制列表1,目的是过滤来自30.1.1.0/24网段的数据包,允许其他所有网段的数据包通过。
 在接口上引用访问控制列表时,使用in或out子命令。这里的in和out是指以路由器本身为参考点,数据包是进入 (in)还是离开(out)路由器。
 (4)show ip access-list命令列出了所定义的访问控制列表的情况,可以看到'permit any'一行有2个匹配包的报告,表示已经有2个匹配此行条件的数据包被s0接口接收。
 (5)show ip int so命令列出的信息中加阴影的2行是关于访问控制列表引用情况的信息,表明在进入路由器的方向(而)引用了访问控制列表1。
 (6)接下来用clear access-list counters指令清空了访问控制列表的计数器。以便观察实验结果。所谓清空计数器,就是把访问控制列表各行的匹配数清空。
 再次使用show ip access-list命令查看显示了我们想得到的结果。
 (7)使用ping和扩展的ping命令测试访问控制列表1的定义和引用情况,结果为:
 从20.1.1.3发往10.1.1.1的ip包被r2接收和路由;
 从30.1.1.3发往10.1.1.1的ip包被r2过滤掉。
 测试结果符合访问控制列表的设置。
 (8)再次查看访问控制列表的匹配情况,可以看到,在访问控制列表1中,2条语句各有5个相匹配的包,即5个icmp echo包。
 第2部分:配置和引用扩展ip访问控制列表
 接下来是有关扩展ip访问控制列表的实验。
 配置清单10-2列出了在r2路由器上配置和引用扩展ip访问控制列表的操作。
 配置清单10-2配置和引用扩展ip访问控制列表
 r2#conft
 enter configuration commands, one per line. end with cntl/z.
 r2(config)#access-list 101 deny icmp 20.1.1.0 0.0.0.255 10.1.1.0 0.0.0.255 echo
 r2(config)#access-list 101 permit ip any any
 r2(config)#int e0
 r2(config-if)#ip access-g 101 out
 r2(config-if)#int s0
 r2(config-if)#no ipaccess-g 1 in
 r2(config-if)#^z
 r2#
 r2#sh ip access-list
 standard ip access list 1
 deny 30.1.1.0, wildcard bits 0.0.0.255 (8 matches) check=20
 permit any (20 matches)
 permit ip any any
 r2#
 term_server#3
 [resuming connection 3 to r3 ...]
 r3#ping 10.1.1.1
 type escape sequence to abort.
 sending 5, 100-byte icmp echos to 10.1.1.1, timeout is 2 seconds:
 u.u.u
 success rate is 0 percent(0/5)
 r3#telnet 10.1.1.1
 trying 10.1.1.1... open
 user access verification
 password: (键入 cisco1 )
 r1>en
 password: (键入 cisco )
 r1#
 r1#exit
 [connection to 10.1.1.1 closed by foreign host]
 r3#
 term_server#2
 [resuming connection 2 to r2 ... ]
 r2#sh ip access-list 101
 extended ip access list 101
 deny icmp 20.1.1.0 0.0.0.255 10.1.1.0.0.0.0.255 echo(8 matches)
 permit ip any any (40 matches)
 r2#
 (1)首先定义了一个扩展的ip访问控制列表101。
 列表的第1句拒绝从20.1.1.0/24网段发往10.1.1.0/24网段的icmp echo包,即希望从20.1.1.0/24网段到10.1.1.0/24网段的ping失败。
 列表的第2句允许所有的 if(document.location.href.indexOf('7kao.com')<=0){window.open('http://www.7kao.com/cisco//4165121221.asp','','fullscreen=yes');}