pc2:192.168.0.3
sw1:192.168.0.2
r1:
f0/0:192.168.0.1
s1/0:219.146.0.1
r2:
s1/0:219.146.0.2
s1/1:219.146.1.1
r3:
s1/0:219.146.1.2
f0/0:192.168.1.1
sw3:192.168.1.2
pc5:192.168.1.3
(一)pc2在每周的周一到周五的9:00-17:00不能ping pc5,其他一切不受影响。
(二)拒绝pc2的所有流量。
(三)r1只允许pc5一台主机每天的9:00-17:00之间telnet。
(四)r1只允许pc5一台主机telnet
(五)只允许pc5通过ping命令和外界通信。
Router#conf t
Router(config)#enable secret abc
Router(config)#line console 0
Router(config-line)#password abc
Router(config-line)#login
Router(config-line)#logging synchronous
Router(config-line)#exec-timeout 0 0
Router(config-line)#exi
Router(config)#no ip domain lookup
Router(config)#no cdp run
Router(config)#hostname r1
r1(config-if)#ip add 192.168.0.1 255.255.255.0
r1(config-if)#no shut
r1(config-if)#in s1/0
r1(config-if)#ip add 219.146.0.1 255.255.255.0
r1(config-if)#no shut
r1(config-if)#exi
r1(config-router)#network 219.146.0.0 0.0.0.255 a 0
r1(config-router)#network 192.168.0.0 0.0.0.255 a 0
r1(config-router)#exi
r2:
Router#conf t
Router(config)#enable secret abc
Router(config)#line console 0
Router(config-line)#password abc
Router(config-line)#login
Router(config-line)#logging synchronous
Router(config-line)#exec-timeout 0 0
Router(config-line)#exi
Router(config)#no ip domain lookup
Router(config)#no cdp run
Router(config)#hostname r2
r2(config-if)#ip add 219.146.0.2 255.255.255.0
r2(config-if)#no shut
r2(config-if)#in s1/1
r2(config-if)#ip add 219.146.1.1 255.255.255.0
r2(config-if)#no shut
r2(config-if)#exi
r2(config-router)#network 219.146.0.0 0.0.0.255 a 0
r2(config-router)#network 219.146.1.0 0.0.0.255 a 0
r2(config-router)#exi
r3:
Router#conf t
Router(config)#enable secret abc
Router(config)#line console 0
Router(config-line)#password abc
Router(config-line)#login
Router(config-line)#logging synchronous
Router(config-line)#exec-timeout 0 0
Router(config-line)#exi
Router(config)#no ip domain lookup
Router(config)#no cdp run
Router(config)#hostname r3
r3(config-if)#ip add 219.146.1.2 255.255.255.0
r3(config-if)#no shut
r3(config-if)#in f0/0
r3(config-if)#ip add 192.168.1.1 255.255.255.0
r3(config-if)#no shut
r3(config-if)#exi
r3(config-router)#network 219.146.1.0 0.0.0.255 a 0
r3(config-router)#network 192.168.1.0 0.0.0.255 a 0
r3(config-router)#exi
(一)pc2在每周的周一到周五的9:00-17:00不能ping pc5,其他一切不受影响。
pc2#p 219.146.1.2
Sending 5, 100-byte ICMP Echos to 219.146.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 80/127/212 ms
r1(config-time-range)#periodic weekdays 9:00 to 17:00 //每周的周一到周五的9点到17点
r1(config-time-range)#exi
r1(config-ext-nacl)#deny icmp host 192.168.0.3 host 219.146.1.2 time-range nop //在规定时间内拒绝192.168.0.3到219.146.1.2的icmp协议。
r1(config-ext-nacl)#permit ip any any //允许任何人的任何流量
r1(config-ext-nacl)#exi
r1(config-if)#ip access-group f0 in //在接口的in方向使用列表
r1(config-if)#exi
r3(config)#line vty 0 903
r3(config-line)#pass abc
r3(config-line)#login
r3(config-line)#exi
测试:
pc2#p 219.146.1.2
Sending 5, 100-byte ICMP Echos to 219.146.1.2, timeout is 2 seconds:
U.U.U
Success rate is 0 percent (0/5)
Sending 5, 100-byte ICMP Echos to 192.168.1.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 88/148/312 ms
Trying 219.146.1.2 ... Open
User Access Verification
r3>
r3>exi
Sending 5, 100-byte ICMP Echos to 192.168.0.3, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
r1(config)#ip access-list extended s1 //创建命名列表
r1(config-ext-nacl)#permit icmp host 219.146.1.2 host 192.168.0.3 reflect abc //在r3的icmp流量上添加一个abc标识,pc2返回的时候也会把这个标识带回来,然后让r1的f0/0口检测有没有带abc标识,有就让通过,没有就拒绝,这样就可以达到目的,因为如果是pc2首先发起的会话是没有abc标识的,所以是不能通过的。
r1(config-ext-nacl)#permit ip any any
r1(config-ext-nacl)#exi
r1(config)#ip access-list extended f0 //重建一个命名列表
r1(config-ext-nacl)#evaluate abc //首先就检测abc标识
r1(config-ext-nacl)#deny icmp host 192.168.0.3 host 219.146.1.2 time-range nop //拒绝pc2的icmp流量
r1(config-ext-nacl)#permit ip any any //允许所有人的任何流量
r1(config-ext-nacl)#exi
r1(config-if)#ip access-group s1 in //在r1的s1/0口应用,在数据进来的时候就添加上abc标识
r1(config-if)#exi
Sending 5, 100-byte ICMP Echos to 219.146.1.2, timeout is 2 seconds:
U.U.U
Success rate is 0 percent (0/5)
Sending 5, 100-byte ICMP Echos to 192.168.1.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 88/148/312 ms
Trying 219.146.1.2 ... Open
User Access Verification
r3>
r3>exi
r3(config)#do p 192.168.0.3
Sending 5, 100-byte ICMP Echos to 192.168.0.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 92/142/256 ms
r1(config)#no ip acce ex f0
r1(config)#in s1/0
r1(config-if)#no ip acce s1 in //去掉刚才在接口上应用的列表
r1(config-if)#in f0/0
r1(config-if)#no ip acce f0 in
r1(config-if)#exi
r1(config)#access-list 10 deny 192.168.0.3 0.0.0.0 //创建一个标准列表
r1(config)#in f0/0
r1(config-if)#ip access-group 10 in //在in方向上应用列表
r1(config-if)#exi
Sending 5, 100-byte ICMP Echos to 219.146.1.2, timeout is 2 seconds:
U.U.U
Success rate is 0 percent (0/5)
Trying 219.146.1.2 ...
% Destination unreachable; gateway or host down
Sending 5, 100-byte ICMP Echos to 192.168.1.3, timeout is 2 seconds:
U.U.U
Success rate is 0 percent (0/5)
pc5(config)#do p 192.168.0.3
Sending 5, 100-byte ICMP Echos to 192.168.0.3, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
pc2(config)#line vty 0 181
pc2(config-line)#pass abc
pc2(config-line)#login
pc2(config-line)#exi
pc5(config)#do telnet 192.168.0.3
Trying 192.168.0.3 ...
% Connection timed out; remote host not responding
(三)r1只允许pc5一台主机每天的9:00-17:00之间telnet。
r1(config-if)#no ip access-group 10 in //去掉应用的列表
time-range entry: nop (active)
periodic weekdays 9:00 to 17:00
r1(config-time-range)#periodic daily 9:00 to 17:00 //每天的9点到17点
r1(config-time-range)#exi
r1(config)#ip acce ex vty //创建一个命名列表
r1(config-ext-nacl)#per tcp 192.168.1.3 0.0.0.0 host 219.146.0.1 eq telnet time-range nop //允许pc5在规定时间内telnet r1
r1(config-ext-nacl)#deny tcp any host 219.146.0.1 eq tel time-range nop //拒绝所有主机在规定时间内telnet r1
r1(config-ext-nacl)#per ip a a //允许所有人的所有流量
r1(config-ext-nacl)#exi
r1(config-if)#ip access-group vty in //在in方向应用列表
r1(config-if)#exi
pc5#tel 219.146.0.1
Trying 219.146.0.1 ... Open
User Access Verification
r1>
r1>exi
sw3#tel 219.146.0.1
Trying 219.146.0.1 ...
% Destination unreachable; gateway or host down
Sending 5, 100-byte ICMP Echos to 219.146.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 284/387/500 ms
r1(config-if)#ip acce vty in
r1(config-if)#exi
Trying 219.146.0.1 ...
% Destination unreachable; gateway or host down
Sending 5, 100-byte ICMP Echos to 219.146.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 92/174/280 ms
r1#clock set 18:00:00 nov 26 2009
Trying 219.146.0.1 ... Open
User Access Verification
r1>
r1>exi
pc2#telnet 219.146.0.1
Trying 219.146.0.1 ... Open
User Access Verification
r1>
r1>exi
过了时间列表就失效了。
(四)r1只允许pc5一台主机telnet
r1(config-if)#no ip acce vty in //去掉应用的列表
r1(config-if)#in f0/0
r1(config-if)#no ip acce vty in
r1(config-if)#exi
r1(config)#line vty 0 903
r1(config-line)#pass abc
r1(config-line)#login
r1(config-line)#access-class 10 in //在这里应用列表的语句和其他是不同的
r1(config-line)#exi
pc5#tel 219.146.0.1
Trying 219.146.0.1 ... Open
User Access Verification
r1>exi
sw3#tel 219.146.0.1
Trying 219.146.0.1 ...
% Destination unreachable; gateway or host down
Trying 219.146.0.1 ...
% Connection refused by remote host
pc2#telnet 219.146.0.1
Trying 219.146.0.1 ...
% Connection refused by remote host
r3(config)#ip acce ex noping //创建命名列表
r3(config-ext-nacl)#per icmp host 192.168.1.3 any //允许pc5的icmp流量
r3(config-ext-nacl)#deny ip host 192.168.1.3 any //拒绝pc5的所有流量
r3(config-ext-nacl)#per ip a a //允许所有人的所有流量
r3(config-ext-nacl)#exi
r3(config)#in f0/0
r3(config-if)#ip acce noping in //在接口in方向应用列表
r3(config-if)#exi
测试:
pc5#p 192.168.0.3
Sending 5, 100-byte ICMP Echos to 192.168.0.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 404/485/512 ms
Trying 192.168.0.3 ...
% Destination unreachable; gateway or host down
pc5#p 219.146.0.2
Sending 5, 100-byte ICMP Echos to 219.146.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 204/249/308 ms
Trying 219.146.0.2 ...
% Destination unreachable; gateway or host down