拓扑:
要求: 创建基于时间的ACL。使得在某个时间段内 r1 和 r2 能够正常通讯。具体实验要求看下面。
首先完成基本配置:
r1:
r1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
r1(config)#inter e0/0
r1(config-if)#ip add 192.168.12.1 255.255.255.0
r1(config-if)#no shu
r1(config-if)#exit
r1(config)#ip route 0.0.0.0 0.0.0.0 e0/0 192.168.12.2
r1(config)#end
r1#
*Mar 1 01:12:12.919: %SYS-5-CONFIG_I: Configured from console by console
r1#wr
Building configuration...
[OK]
r1#
r2:
r2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
r2(config)#int e0/0
r2(config-if)#ip add 192.168.12.2 255.255.255.0
r2(config-if)#no shu
r2(config-if)#exit
r2(config)#int e0/1
r2(config-if)#ip add 192.168.23.2 255.255.255.0
r2(config-if)#no shu
r2(config-if)#exi
r2(config-if)#exit
r2(config)#end
r2#wr
Building configuration...
*Mar 1 00:12:34.483: %SYS-5-CONFIG_I: Configured from console by console[OK]
r2#
r3:
r3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
r3(config)#int e0/1
r3(config-if)#ip add 192.168.23.3 255.255.255.0
r3(config-if)#no shu
r3(config-if)#exit
r3(config)#ip route 0.0.0.0 0.0.0.0 e0/1 192.168.23.2
r3(config)#end
r3#wr
Building configuration...
*Mar 1 00:13:38.063: %SYS-5-CONFIG_I: Configured from console by console[OK]
r3#
然后测试网络连通性:
r1#ping 192.168.23.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/45/84 ms
r1#
r1 和 r3 可以正常访问 。
查看 r2 的时间:
r2#show clock
*00:16:31.627 UTC Fri Mar 1 2002
r2#
我们要求在时间段 00:00 到 00:30 之间 r1 和 r3 能够通讯,其他时间不能通讯。
我们在 r2 上面做基于时间的访问控制列表:
r2#conf t
r2(config)#time-range acl_time //创建名称为acl_time的时间段
r2(config-time-range)#absolute start 00:00 1 mar 2002 end 00:30 1 mar 2002
r2(config)#ip access-list extended 101 //创建扩展ACL
r2(config-ext-nacl)#permit ip host 192.168.12.1 host 192.168.23.3
time-range acl_time
r2(config-ext-nacl)#exit
r2(config)#interface e0/0
r2(config-if)#ip access-group 101 in //在接口上面引用
r2(config-if)#end
r2#
*Mar 1 00:24:15.867: %SYS-5-CONFIG_I: Configured from console by console
r2#
完成后在 r1 上面测试:
r1#ping 192.168.23.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/56/152 ms
r1#
在这个时间段内 r1 和 r3 能够通讯。
这个时候我们在 r1 上面用扩展的 PING 测试,同时我们更改 r2 的时间,使得其不在这个时间段内:
r1#ping
Protocol [ip]:
Target IP address: 192.168.23.3
Repeat count [5]: 10000
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 10000, 100-byte ICMP Echos to 192.168.23.3, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! U.U.U.U.U.U.U.U.U.!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!
Success rate is 87 percent (134/153), round-trip min/avg/max = 8/31/104 ms
r1#
r1#
在上面的 PING 测试过程中我两次更改了 r2 的时间:
r2#clock set 00:50:00 1 mar 2002
r2#
Mar 1 00:50:00.003: %SYS-6-CLOCKUPDATE: System clock has been updated from 00:20:34 UTC Fri Mar 1 2002 to 00:50:00 UTC Fri Mar 1 2002, configured from console by console.
r2#
r2#
r2#
r2#
r2#clock set 00:10:00 1 mar 2002
r2#
Mar 1 00:10:00.000: %SYS-6-CLOCKUPDATE: System clock has been updated from 00:50:17 UTC Fri Mar 1 2002 to 00:10:00 UTC Fri Mar 1 2002, configured from console by console.
r2#
可以很清晰的看得见如果 r2 的时间不再 00:00 - 00:30 时间段内的时候 r1 和 r2 不能正常通讯。
总结:
上面的誓言只是很简单的测试,我们实际应用还可以做基于端口和时间的访问控制列表,满足我们日常网络管理的需要。
本实验平台基于 DynamipsGUI 2.83 未注册版,感谢小凡