問題
在網(wǎng)絡(luò)中很有可能要允許或拒絕的并不是某一個(gè)源IP地址吴汪,而是根據(jù)目標(biāo)地址或是協(xié)議來匹配示辈。但是標(biāo)準(zhǔn)訪問控制列表只能根據(jù)源IP地址來決定是否允許一個(gè)數(shù)據(jù)包通過可缚。
配置擴(kuò)展ACL允許pc1訪問pc4的www服務(wù)但拒絕訪問PC4的其他服務(wù)熔酷,PC2缝左、PC3無限制成肘。
方案
為了實(shí)現(xiàn)更靈活卖局、列精確的網(wǎng)絡(luò)控制就需要用到擴(kuò)展訪問控制列表了。
擴(kuò)展IP訪問控制列表比標(biāo)準(zhǔn)IP訪問控制列表具有更多的匹配項(xiàng)双霍,包括協(xié)議類型砚偶、源地址、目的地址店煞、源端口蟹演、目的端口、建立連接的和IP優(yōu)先級(jí)等顷蟀。
步驟
1.在三臺(tái)路由器中配置IP酒请、RIP動(dòng)態(tài)路由實(shí)現(xiàn)全網(wǎng)互通
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服務(wù)后在PC1、PC2和PC3上驗(yàn)證到Web Server的HTTP協(xié)議訪問
在沒有配置擴(kuò)展ACL的時(shí)候鸣个,主機(jī)均可以正常訪問到Web Server羞反。
3.R1上配置擴(kuò)展訪問控制列表布朦,PC1僅允許到Web Server的HTTP服務(wù)(不允許訪問其他服務(wù)),PC2昼窗、PC3無限制
擴(kuò)展ACL可以對數(shù)據(jù)包中的源是趴、目標(biāo)IP地址以及端口號(hào)進(jìn)行檢查,所以可以將該ACL放置在通信路徑中的任一位置澄惊。但是唆途,如果放到離目標(biāo)近的地方,每臺(tái)路由器都要對數(shù)據(jù)進(jìn)行處理掸驱,會(huì)更多的消耗路由器和帶寬資源肛搬。放到離源最近的路由器端口入方向直接就將拒絕數(shù)據(jù)丟棄,可以減少其他路由器的資源占用以及帶寬占用毕贼。
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這是屬于標(biāo)準(zhǔn)的訪問控制列表而100以上的屬于擴(kuò)展
4.在PC1上驗(yàn)證
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),
從輸入結(jié)果可以驗(yàn)證温赔,PC1到Web Server的http服務(wù)訪問沒有受到影響但不能ping通Web Server。
5.在PC2上進(jìn)行驗(yàn)證
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上查看相關(guān)的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))