防火牆的配置與acl相關配置
拓撲圖如下(學號14):
配置靜態路由:
R1(config)#int f0/0
R1(config-if)#ip address 10.14.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#int f0/1
R1(config-if)#ip address 14.14.2.1 255.255.255.0
R1(config-if)#no shutdown
R4(config)#ip route 10.14.1.0 255.255.255.0 14.14.2.1
R3(config)#ip route 14.14.2.0 255.255.255.0 10.14.1.1
R2(config)#ip route 14.14.2.0 255.255.255.0 10.14.1.1
測試網絡是否Ping通:
R1pingR4
R2pingR4
標准acl
R4(config)#access-list 1 deny 10.14.1.2 0.0.0.0
R4(config)#int f0/1
R4(config-if)#ip access-group 1 in
R4(config-if)#end
自反acl
R1(config)#ip access-list extended come
R1(config-ext-nacl)#permit icmp any any
R1(config-ext-nacl)#evaluate abc
R1(config)#int f0/1
R1(config-if)#ip access-group come in
說明ICMP是可以任意訪問的
R1(config)#ip access-list extended goto
R1(config-ext-nacl)#permit tcp any any eq telnet reflect abc timeout 60
R1(config-ext-nacl)#permit ip any any
R1(config)#int f0/1
R1(config-if)#ip access-group goto out
動態acl
R1(config)#access-list 100 permit tcp an an eq telnet
R1(config)#access-list 100 dynamic ccie timeout 2 permit icmp any any
R1(config)#int f0/0
R1(config-if)#ip access-group 100 in
配置本地用戶數據庫
R1(config)#username ccie password ysx
R1(config)#line vty 0 181
R1(config-line)#login local
R1(config-line)#autocommand access-enable
R1#show ip access-lists
Extended IP access list 100
10 permit tcp any any eq telnet (84 matches)
20 Dynamic ccie permit icmp any any
Reflexive IP access list abc
Extended IP access list come
10 permit icmp any any (35 matches)
20 evaluate abc
Extended IP access list goto
10 permit tcp any any eq telnet reflect abc (23 matches)
20 permit ip any any (15 matches)
基於時間的acl
R1(config)#time-range TELNET
R1(config-time-range)#periodic weekdays 9:00 to 14:00
R1(config)#access-list 150 deny tcp host 10.14.1.2 any eq 23 time TELNET
R1(config)#$ 150 deny tcp host 10.14.1.2 any eq 23 time-range TELNET
R1(config)#access-list 150 permit ip any any
R1(config)#int f0/0
R1(config-if)#ip access-group 150 in
查看路由器時間
測試R2向R4發起telnet會話
r2#telnet 14.14.2.4
Trying 14.14.2.4 ...
% Destination unreachable; gateway or host down
r2#
說明:可以看到,在規定的時間范圍內,R2向R4發起telnet會話是被拒絕的。
測試除telnet外的其它流量
r2#ping 14.14.2.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 14.14.2.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
r2#
說明:可以看到,在規定的時間范圍內,除了telnet之外,其它流量不受限制
查看當前R1的時間
r1#sh clock
測試R2向R4發起telnet會話
r2#telnet 14.14.2.4
Trying 14.14.2.4 ... Open
r4>
說明:在時間范圍之外,所限制的流量被放開。