實驗3-1 配置ACL過濾企業數據
學習目標
掌握高級ACL的配置方法
掌握ACL在接口下的應用方法
拓撲圖
場景
企業部署了三個網絡,其中R2連接的是公司總部網絡,R1和R3分別爲兩個不同分支網絡的設備,這三臺路由器通過廣域網相連。你需要控制員工使用Telnet和FTP服務的權限,R1所在分支的員工只允許訪問公司總部網絡中的Telnet服務器,R3所在分支的員工只允許訪問FTP服務器。
操作步驟
步驟一 實驗環境準備
S1
[S1]vlan 4
[S1-vlan4]
[S1-vlan4]quit
[S1]un in en
Info: Information center is disabled.
[S1]int vlan 4
[S1-Vlanif4]ip add 10.0.4.254 24
S2
[S2]un in en
Info: Information center is disabled.
[S2]vlan 6
[S2-vlan6]quit
[S2]int vlan 6
[S2-Vlanif6]ip add 10.0.6.254 24
[S2-Vlanif6]quit
步驟二 配置IP地址
R1
interface GigabitEthernet0/0/0
ip address 10.0.13.1 255.255.255.0
R2
interface GigabitEthernet0/0/0
ip address 10.0.13.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 10.0.4.2 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 10.0.6.2 255.255.255.0
R3
interface GigabitEthernet0/0/0
ip address 10.0.13.3 255.255.255.0
配置S1和S2連接路由器的端口爲Trunk端口,並通過修改PVID使物理端口加入三層VLANIF邏輯接口。
S1
interface GigabitEthernet0/0/2
port link-type trunk
port trunk pvid vlan 4
port trunk allow-pass vlan 4
S2
interface GigabitEthernet0/0/2
port link-type trunk
port trunk pvid vlan 6
port trunk allow-pass vlan 2 to 4094
配置OSPF使網絡互通
R1
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 10.0.13.0 0.0.0.255
R2
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 10.0.13.0 0.0.0.255
network 10.0.4.0 0.0.0.255
network 10.0.6.0 0.0.0.255
R3
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 10.0.13.0 0.0.0.255
在S1和S2上配置缺省靜態路由,指定下一跳爲各自連接的路由器網關
[S1]ip route-static 0.0.0.0 0.0.0.0 10.0.4.2
[S2]ip route-static 0.0.0.0 0.0.0.0 10.0.6.2
這裏使用R3PingR1
網絡出現環路
Reply from 10.0.13.1: bytes=56 Sequence=2 ttl=245 time=1690 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=2 ttl=247 time=1690 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=2 ttl=247 time=1690 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=2 ttl=247 time=1690 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=2 ttl=247 time=1690 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=2 ttl=249 time=1690 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=2 ttl=249 time=1690 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=3 ttl=249 time=1110 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=3 ttl=249 time=1110 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=2 ttl=249 time=1690 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=2 ttl=251 time=1690 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=3 ttl=251 time=1110 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=3 ttl=251 time=1110 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=2 ttl=251 time=1690 ms (DUP!)
Reply from 10.0.13.1: bytes=56 Sequence=2 ttl=253 time=1690 ms (DUP!)
將R2的G0/0/0接口shutdown後環路消失。
步驟三 配置ACL過濾報文
將S1配置成Telnet服務器
[S1]telnet server enable
Info: The Telnet server has been enabled.
[S1]user-interface vty 0 4
[S1-ui-vty0-4]protocol inbound all
[S1-ui-vty0-4]aut
[S1-ui-vty0-4]authentication-mode password
[S1-ui-vty0-4]set au
[S1-ui-vty0-4]set authentication pass
[S1-ui-vty0-4]set authentication password cip
[S1-ui-vty0-4]set authentication password cipher huawei123
將S2配置成FTP服務器
[S2]ftp server enable
Info: Succeeded in starting the FTP server.
[S2]aaa
[S2-aaa]local-user huawei password cipher huawei123
Info: Add a new user.
[S2-aaa]
[S2-aaa]
[S2-aaa]local-user huawei priv
[S2-aaa]local-user huawei privilege l
[S2-aaa]local-user huawei privilege level 3
[S2-aaa]loc
[S2-aaa]local-user huawei service-ty
[S2-aaa]local-user huawei service-type ftp
[S2-aaa]local-user huawei ftp-dire
[S2-aaa]local-user huawei ftp-directory flash:/
在R2上配置ACL,只允許R1訪問Telnet服務器,只允許R3訪問FTP服務器
R2
ACL's step is 5
rule 5 permit 23 source 10.0.13.1 0 destination 10.0.4.254 0 (0 times matched)
rule 10 permit 22 source 10.0.13.2 0 destination 10.0.6.254 0 (0 times matched)
rule 15 permit ospf (0 times matched)
rule 20 deny ip (0 times matched)
在R2的G0/0/0接口上應用ACL
似乎在普通的ROUTER上不能將ACL應用到接口上。
附加練習:分析並驗證
爲什麼FTP要求ACL定義兩個端口
默認情況下FTP協議使用TCP端口中的 20和21這兩個端口,其中20用於傳輸數據,21用於傳輸控制信息。
但是,是否使用20作爲傳輸數據的端口與FTP使用的傳輸模式有關,如果採用主動模式,那麼數據傳輸端口就是20;如果採用被動模式,則具體最終使用哪個端口要服務器端和客戶端協商決定。
應在源端網絡還是目標網絡配置基本ACL和高級ACL爲什麼
基本ACL放置在目的端的路由器
高級ACL放置在源端的路由器