問題
在網絡中很有可能要允許或拒絕的并不是某一個源IP地址,而是根據目標地址或是協議來匹配。但是標準訪問控制列表只能根據源IP地址來決定是否允許一個數據包通過。
配置擴展ACL允許pc1訪問pc4的www服務但拒絕訪問PC4的其他服務,PC2、PC3無限制。
方案
為了實現更靈活、列精確的網絡控制就需要用到擴展訪問控制列表了。
擴展IP訪問控制列表比標準IP訪問控制列表具有更多的匹配項,包括協議類型、源地址、目的地址、源端口、目的端口、建立連接的和IP優先級等。
步驟
1.在三臺路由器中配置IP、RIP動態路由實現全網互通
tarena-R1(config)#interface fastEthernet 0/0
tarena-R1(config-if)#ip address 192.168.1.254 255.255.255.0
tarena-R1(config-if)#no shutdown
tarena-R1(config-if)#exit
tarena-R1(config)#interface fastEthernet 0/1
tarena-R1(config-if)#ip address 192.168.2.1 255.255.255.0
tarena-R1(config-if)#no shutdown
tarena-R1(config-if)#exit
tarena-R1(config)#router rip
tarena-R1(config-router)#no auto-summary
tarena-R1(config-router)#version
tarena-R1(config-router)#network 192.168.1.0
tarena-R1(config-router)# network192.168.2.0
tarena-R2(config)#interface fastEthernet 0/1
tarena-R2(config-if)#ip address 192.168.2.2 255.255.255.0
tarena-R2(config-if)#no shutdown
tarena-R2(config-if)#exit
tarena-R2(config)#interface fastEthernet 0/0
tarena-R2(config-if)#ip address 192.168.3.1 255.255.255.0
tarena-R2(config-if)#exit
tarena-R2(config)#router rip
tarena-R2(config-router)#version 2
tarena-R2(config-router)#no auto-summary
tarena-R2(config-router)#network 192.168.2.0
tarena-R2(config-router)#network 192.168.3.0
tarena-R3(config)# interface fastEthernet 0/0
tarena-R3(config-if)#ip add 192.168.3.2 255.255.255.0
tarena-R3(config-if)#no shu
tarena-R3(config-if)#exit
tarena-R3(config)#interface fastEthernet 0/1
tarena-R3(config-if)#ip address 192.168.4.254 255.255.255.0
tarena-R3(config-if)#no shutdown
tarena-R3(config-if)#exit
tarena-R3(config)#router rip
tarena-R3(config-router)#version 2
tarena-R3(config-router)#no auto-summary
tarena-R3(config-router)#network 192.168.3.0
tarena-R3(config-router)#network 192.168.4.0
2.開啟192.168.4.1的http服務后在PC1、PC2和PC3上驗證到Web Server的HTTP協議訪問
在沒有配置擴展ACL的時候,主機均可以正常訪問到Web Server。
3.R1上配置擴展訪問控制列表,PC1僅允許到Web Server的HTTP服務(不允許訪問其他服務),PC2、PC3無限制
擴展ACL可以對數據包中的源、目標IP地址以及端口號進行檢查,所以可以將該ACL放置在通信路徑中的任一位置。但是,如果放到離目標近的地方,每臺路由器都要對數據進行處理,會更多的消耗路由器和帶寬資源。放到離源最近的路由器端口入方向直接就將拒絕數據丟棄,可以減少其他路由器的資源占用以及帶寬占用。
tarena-R1(config)#access-list 100 permit tcp host 192.168.1.1 host 192.168.4.1 eq 80
tarena-R1(config)#access-list 100 deny ip host 192.168.1.1 host 192.168.4.1
tarena-R1(config)#access-list 100 permit ip 192.168.1.0 0.0.0.255 host 192.168.4.1
tarena-R1(config)#interface fastEthernet 0/0
tarena-R1(config-if)# ip?access-group 100 in //access-list 1到99這是屬于標準的訪問控制列表而100以上的屬于擴展
4.在PC1上驗證
PC>ipconfig
FastEthernet0 Connection:(default port)
Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
IP Address......................: 192.168.1.1
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.1.254
PC>ping 192.168.4.
Pinging 192.168.4.1 with 32 bytes of data:
Reply from 192.168.1.254: Destination host unreachable.
Reply from 192.168.1.254: Destination host unreachable.
Reply from 192.168.1.254: Destination host unreachable.
Reply from 192.168.1.254: Destination host unreachable.
Ping statistics for 192.168.4.1:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
從輸入結果可以驗證,PC1到Web Server的http服務訪問沒有受到影響但不能ping通Web Server。
5.在PC2上進行驗證
PC>ipconfig
FastEthernet0 Connection:(default port)
Link-local IPv6 Address.........: FE80::209:7CFF:FED5:B0E4
IP Address......................: 192.168.1.2
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.1.254
PC>ping 192.168.4.1
Pinging 192.168.4.1 with 32 bytes of data:
Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
Reply from 192.168.4.1: bytes=32 time=12ms TTL=125
Reply from 192.168.4.1: bytes=32 time=13ms TTL=125
Reply from 192.168.4.1: bytes=32 time=12ms TTL=125
Ping statistics for 192.168.4.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 13ms, Average = 9ms
6.在R1上查看相關的ACL信息
tarena-R1#show ip access-lists
Extended IP access list 100
10 permit tcp host 192.168.1.1 host 192.168.4.1 eq www (5 match(es))
20 deny ip host 192.168.1.1 host 192.168.4.1 (4 match(es))
30 permit ip 192.168.1.0 0.0.0.255 host 192.168.4.1 (8 match(es))