擴展ACL:
可以同時匹配IP數據包的(源IP 目標IP) 傳輸層協議網絡
IP-ACL(3層ACL,針對的是3層流量) 擴展ACL匹配流量,更加精確: 肯定流量的惟一5元組: 源IP、目標IP、源端口、目標端口、傳輸層協議。 對數據而言,凡是可以經過「傳輸層協議+端口號」的方式 進行表示的,則表示該數據是屬於「應用層」。 路由器查找路由表時,有一個最長匹配原則, 匹配的越長,表示地址越精確。
實驗名稱:擴展ACL的原理與應用
實驗拓撲:tcp
實驗需求:
R1能夠ping通R4;
R1的 loopback 10 沒法 telnet R4 ;
實驗步驟:
一、確保網絡互通
基於拓撲圖,配置設備端口地址;
配置靜態路由,確保網段互通;
&默認路由: 0.0.0.0 0.0.0.0 -> 0.0.0.0/0 ,表示全部網絡。ide
二、配置ACL策略 想要抓取一個流量 必須瞭解一個流量 配置命令:(R2) ip access-list extended Deny-telnet 10 deny tcp 10.10.1.0 0.0.0.255 10.10.4.0 0.0.0.255 eq telnet 20 deny tcp 10.10.1.0 0.0.0.255 192.168.34.0 0.0.0.255 eq telnet 30 permit ip any any
!
或者oop
ip access-list extended Deny-telnet 10 deny tcp 10.10.1.1 0.0.0.0 10.10.4.4 0.0.0.0 eq telnet 20 deny tcp 10.10.1.1 0.0.0.0 192.168.34.4 0.0.0.0 eq telnet 30 permit ip 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255 三、調用ACL策略 R2: interface fas0/1 ip access-group Deny-telnet in 四、驗證ACL策略 R2: show ip access-list show ip interface fas0/1 R1: telnet 10.10.4.4 /source-interface loopback 0 -> no telnet 192.168.34.4 /source-interface loopback 0 -> no 其餘全部地址之間的全部類型流量,都是通的。
注意:
ACL不會對本地設備發起的流量起做用,僅僅對穿越流量起做用;
實驗過程:
R1>en
R1#conf
R1#configure t
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int f0/0
R1(config-if)#no shu
R1(config-if)#ip add 192.
Dec 11 20:51:01.215: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
Dec 11 20:51:02.215: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#ip add 192.168.12.1 255.255.255.0
R1(config-if)#exit
R1(config)#int l
R1(config)#int loopback 10
R1(config-if)#ip add 10.10.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#ip routing
R1(config)#ip route 192.168.23.0 255.255.255.0 192.168.12.2
R1(config)#no ip route 192.168.23.0 255.255.255.0 192.168.12.2
R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.12.2
R1(config)#exit
R1#ping 192.168.34.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.34.4, timeout is 2 seconds:
...!!
Success rate is 40 percent (2/5), round-trip min/avg/max = 88/90/92 ms
R1#ping 192.168.34.4code
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.34.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 100/135/192 ms
R1# telnet 10.10.4.4 /source-interface loopback 10
Trying 10.10.4.4 ...
% Connection timed out; remote host not respondingip
R2>
R2>en
R2#conf
R2#configure t
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int f0/1
R2(config-if)#no shu
R2(config-if)#ip add
Dec 11 20:55:18.379: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
Dec 11 20:55:19.379: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2(config-if)#ip add 192.168.12.2 255.255.255.0
R2(config-if)#exit
R2(config)#int f0/0
R2(config-if)#no shu
R2(config-if)#ip add 192.168.23.2 255.255.255.0
R2(config-if)#exit
R2(config)#ip routing
R2(config)#ip route 192.168.34.0 255.255.255.0 192.168.23.3
R2(config)#ip route 10.10.1.0 255.255.255.0 192.168.23.3
R2(config)#ip route 10.10.4.0 255.255.255.0 192.168.23.3
R2(config)#exit
R2#conf
R2#configure t
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#ip access-list extended deny-telnet(設置擴展ACL拒絕遠程訪問)
R2(config-ext-nacl)#10 deny tcp 10.10.1.1 0.0.0.0 10.10.4.4 0.0.0.0 eq 23 (拒絕 tcp是第7層應用層,源主機 精確位數 目標主機 精確位數 eq是等於 協議telnet或23是知名端口)
R2(config-ext-nacl)#20 deny tcp 10.10.1.1 0.0.0.0 192.168.34.0 0.0.0.255 eq$ 10.10.1.1 0.0.0.0 192.168.34.0 0.0.0.255 eq 23
R2(config-ext-nacl)#30 permit ip any any(容許全部)
R2(config-ext-nacl)#exit
R2(config)#int fas0/1
R2(config-if)#ip acces
R2(config-if)#ip access-group deny-telnet in(對應端口)
R2(config-if)#exit
R2(config)#路由
R3>en
R3#conf
R3#configure t
R3#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int f0/1
R3(config-if)#no shu
R3(config-if)#ip add 192.168.23.3 255.255.255.0
R3(config-if)#exit
R3(config)#int f0/0
R3(config-if)#no shu
R3(config-if)#ip add 192.168.34.3 255.255.255.0
R3(config-if)#exit
R3(config)#ip routing
R3(config)#ip route 192.168.12.0 255.255.255.0 192.168.23.2
R3(config)#ip route 10.10.1.0 255.255.255.0 192.168.23.2
R3(config)#ip route 10.10.4.0 255.255.255.0 192.168.34.4rem
R4>en
R4#conf
R4#configure t
R4#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R4(config)#int f0/0
R4(config-if)#no shu
R4(config-if)#ip add 192.168.34.4 255.255.255.0
R4(config-if)#exit
R4(config)#int l
R4(config)#int loopback 20 (虛擬端口,迴環)
R4(config-if)#ip add 10.10.4.4 255.255.255.0
R4(config-if)#exit
R4(config)#ip routing
R4(config)#ip route 0.0.0.0 0.0.0.0 192.168.34.3
R4(config)#ena
R4(config)#enable p
R4(config)#enable password 123
R4(config)#li
R4(config)#line vt
R4(config)#line vty 0 4 (設置遠程訪問)
R4(config-line)#pass
R4(config-line)#password 123456
R4(config-line)#terminal