配置標準ACL
1.1 問題
絡調通後,保證網絡是通暢的。同時也極可能出現未經受權的非法訪問。企業網絡既要解決連連通的問題,還要解決網絡安全的問題。安全
- 配置標準ACL實現拒絕PC1(IP地址爲192.168.1.1)對外問網絡192.168.2.1的訪問
1.2 方案
訪問控制是網絡安全防範和保護的主要策略,它的主要任務是保證網絡資源不被非法使用和訪問。它是保證網絡安全最重要的核心策略之一。網絡
訪問控制列表(Access Control Lists,ACL)是應用在路由器接口的指令列表。這些指令列表用來告訴路由器哪能些數據包能夠收、哪能數據包須要拒絕。至於數據包是被接收仍是拒絕,能夠由相似於源地址、目的地址、端口號等的特定指示條件來決定。tcp
標準訪問控制列表只能根據數據包的源IP地址決定是否容許經過。測試
網絡拓撲如圖-1所示:spa
圖-1orm
1.3 步驟
實現此案例須要按照以下步驟進行。router
步驟一:在R1上配置接口IP接口
- tarena-R1(config)#interface f0/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)#interface f0/1
- tarena-R1(config-if)#ip address 192.168.2.254 255.255.255.0
- tarena-R1(config-if)#no shutdown
步驟二:測試主機到192.168.2.1的連通性網絡安全
在實施ACL以前先檢查網絡是否可以正常通訊,由於沒有任何限制,網絡應該是處於連通狀態。ip
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.2.100
- Pinging 192.168.2.100 with 32 bytes of data:
- Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
- Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
- Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
- Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
- Ping statistics for 192.168.2.1:
- Packets: Sent = 4, Received = 2, Lost = 2 (50% loss),
- Approximate round trip times in milli-seconds:
- Minimum = 0ms, Maximum = 0ms, Average = 0ms
- PC>
PC2測試以下所示:
- PC>ipconfig
- FastEthernet0 Connection:(default port)
- Link-local IPv6 Address.........: FE80::2D0:BAFF:FE98:9E29
- IP Address......................: 192.168.1.2
- Subnet Mask.....................: 255.255.255.0
- Default Gateway.................: 192.168.1.254
- PC>ping 192.168.2.1
- Pinging 192.168.2.1 with 32 bytes of data:
- Reply from 192.168.2.1: bytes=32 time=2ms TTL=126
- Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
- Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
- Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
- Ping statistics for 192.168.2.1:
- Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
- Approximate round trip times in milli-seconds:
- Minimum = 0ms, Maximum = 2ms, Average = 0ms
- PC>
步驟三:在R1上配置標準訪問控制列表,並應用到Fa0/0端口
ACL的匹配規則中,最後有一條隱含拒絕所有。若是語句中所有是拒絕條目,那麼最後必須存在容許語句,不然全部數據通訊都將被拒絕。
- tarena-R1(config)#access-list 1 deny host 192.168.1.1
- tarena-R1(config)#access-list 1 permit 192.168.1.0 0.0.0.255
- tarena-R1(config)#interface f0/0
- tarena-R1(config-if)#ip access-group 1 in
步驟四:分別在兩臺主機上測試到192.168.2.1的連通性
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.2.1
- Pinging 192.168.2.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.2.1:
- Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
- PC>
PC2測試以下所示:
- PC>ipconfig
- FastEthernet0 Connection:(default port)
- Link-local IPv6 Address.........: FE80::207:ECFF:FE46:CAC0
- IP Address......................: 192.168.1.2
- Subnet Mask.....................: 255.255.255.0
- Default Gateway.................: 192.168.1.254
- PC>ping 192.168.2.1
- Pinging 192.168.2.1 with 32 bytes of data:
- Reply from 192.168.2.1: bytes=32 time=1ms TTL=127
- Reply from 192.168.2.1: bytes=32 time=0ms TTL=127
- Reply from 192.168.2.1: bytes=32 time=1ms TTL=127
- Reply from 192.168.2.1: bytes=32 time=0ms TTL=127
- Ping statistics for 192.168.2.1:
- Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
- Approximate round trip times in milli-seconds:
- Minimum = 0ms, Maximum = 1ms, Average = 0ms
- PC>
結果顯示PC2(IP地址爲192.168.1.2)能夠正常訪問192.168.2.1,而PC1(IP地址爲192.168.1.1)已經被192.168.1.254(R1)拒絕。
步驟五:在R1上查看相關的ACL信息
- tarena-R1#show ip access-lists
- Standard IP access list 1
- 10 deny host 192.168.1.1 (4 match(es))
- 20 permit 192.168.1.0 0.0.0.255 (8 match(es)
2 案例2:配置擴展ACL
在網絡中頗有可能要容許或拒絕的並非某一個源IP地址,而是根據目標地址或是協議來匹配。可是標準訪問控制列表只能根據源IP地址來決定是否容許一個數據包經過。
2.1 問題
配置擴展ACL容許pc1訪問pc4的www服務但拒絕訪問PC4的其餘服務,PC二、PC3無限制。
2.2 方案
爲了實現更靈活、列精確的網絡控制就須要用到擴展訪問控制列表了。
擴展IP訪問控制列表比標準IP訪問控制列表具備更多的匹配項,包括協議類型、源地址、目的地址、源端口、目的端口、創建鏈接的和IP優先級等。
網絡拓撲如圖-2所示:
圖-2
2.3 步驟
實現此案例須要按照以下步驟進行。
步驟一:在三臺路由器中配置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)#network 192.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
步驟二:開啓192.168.4.1的http服務後在PC一、PC2和PC3上驗證到Web Server的HTTP協議訪問,均如圖3所示:
圖-3
在沒有配置擴展ACL的時候,主機都可以正常訪問到Web Server。
步驟三:R1上配置擴展訪問控制列表,PC1僅容許到Web Server的HTTP服務(不容許訪問其餘服務),PC二、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
步驟四:在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.1
- 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),
- PC>
HTTP協議的驗證如圖-4所示:
圖-4
從輸入結果能夠驗證,PC1到Web Server的http服務訪問沒有受到影響但不能ping通Web Server。
步驟五:在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
HTTP協議的驗證,如圖-5所示:
圖-5
步驟六:在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))
3 案例3:配置標準命名ACL
3.1 問題
使用基本編號的ACL沒有實際意義,只有經過閱讀具體的條目才能得知該ACL的做用。並且ACL的編號有限制,如傳統的標準ACL用1~99表示,擴展ACL用100~199表示。
- 配置標準命名ACL實現192.168.1.0網段拒絕PC1訪問外部網絡,其餘主機無限制。
3.2 方案
命名訪問控制列表能夠爲ACL起一個有意義的名字,經過名稱就能夠得知該ACL要實現什麼功能。同時,由於使用的是名稱而不是數字,也就沒有了ACL數量上的限制。
網絡拓撲如圖-6所示:
圖-6
3.3 步驟
實現此案例須要按照以下步驟進行。
步驟一:將案例1配置標準ACL中的擴展訪問控制列表移除,其餘配置保留
- tarena-R1(config)#interface f0/0
- tarena-R1(config-if)#no ip access-group 1 in
- tarena-R1(config-if)#exit
- tarena-R1(config)#no access-list 1
步驟二:在R2上配置標準的命名訪問控制列表
命名訪問控制列表的配置整體上和用數字表示的ACL同樣,可是更加靈活。
- tarena-R2(config)#ip access-list standard tedu
- tarena-R2(config-std-nacl)#deny host 192.168.1.1
- tarena-R2(config-std-nacl)#permit 192.168.1.0 0.0.0.255
- tarena-R2(config-std-nacl)#exit
- tarena-R2(config)#interface f0/0
- tarena-R2(config-if)#ip access-group tedu in
步驟三:分別在PC1和PC2上作連通性測試
PC2測試以下所示:
- PC>ipconfig
- FastEthernet0 Connection:(default port)
- Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
- IP Address......................: 192.168.1.2
- Subnet Mask.....................: 255.255.255.0
- Default Gateway.................: 192.168.0.1
- 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=126
- Reply from 192.168.4.1: bytes=32 time=0ms TTL=126
- Reply from 192.168.4.1: bytes=32 time=0ms TTL=126
- Reply from 192.168.4.1: bytes=32 time=0ms TTL=126
- 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 = 0ms, Average = 0ms
- PC>
PC1 測試以下所示:
- PC>ipconfig
- FastEthernet0 Connection:(default port)
- Link-local IPv6 Address.........: FE80::2D0:BAFF:FE98:9E29
- IP Address......................: 192.168.1.1
- 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.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),
- PC>
輸出結果代表,PC1的訪問是正常的,而PC2到Web Server的訪問被R2(IP地址爲192.168.1.2)拒絕。
步驟四:在R1上查看相關的ACL信息
- tarena-R2#show ip access-lists
- Standard IP access list tedu
- 10 deny host 192.168.1.1 (4 match(es))
- 20 permit 192.168.1.0 0.0.0.255(4 match(es))
輸出結果也代表,來自於PC1的數據包被攔截。
4 配置擴展命名ACL
4.1 問題
使用基本編號的ACL沒有實際意義,只有經過閱讀具體的條目才能得知該ACL的做用。並且ACL的編號有限制,如傳統的標準ACL用1~99表示,擴展ACL用100~199表示。
- 配置擴展命名ACL容許PC1訪問192.168.4.1的www服務但拒絕訪問192.168.4.1的其餘服務,PC二、PC3無限制。
4.2 方案
命名訪問控制列表能夠爲ACL起一個有意義的名字,經過名稱就能夠得知該ACL要實現什麼功能。同時,由於使用的是名稱而不是數字,也就沒有了ACL數量上的限制。
網絡拓撲如圖-7所示:
圖-7
4.3 步驟
實現此案例須要按照以下步驟進行。
步驟一:將2配置擴展ACL中的擴展訪問控制列表移除,其餘配置保留
- tarena-R1(config)#no access-list 100 permit tcp host 192.168.1.1 host 192.168.4.1 eq www
- tarena-R1(config)#interface fastEthernet 0/0
- tarena-R1(config-if)#no ip access-group 100 in
步驟二:在R1上配置擴展命名訪問控制列表
命名訪問控制列表的配置整體上和用數字表示的ACL同樣,可是更加靈活。
- tarena-R1(config)#ip access-list extended tarena
- tarena-R1(config-ext-nacl)#permit tcp host 192.168.1.1 host 192.168.4.1 eq 80
- tarena-R1(config-ext-nacl)#deny ip host 192.168.1.1 host 192.168.4.1
- tarena-R1(config-ext-nacl)#permit ip 192.168.1.0 0.0.0.255 host 192.168.4.1
- tarena-R1(config)#interface fastEthernet 0/0
- tarena-R2(config-if)#ip access-group tarena in
步驟三:在R1上查看相關的ACL信息
- tarena-R1#show ip access-lists
- Extended IP access list tarena
- 10 permit tcp host 192.168.1.1 host 192.168.4.1 eq www
- 20 deny ip host 192.168.1.1 host 192.168.4.1
- 30 permit ip 192.168.1.0 0.0.0.255 host 192.168.4.1
步驟四:在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.1
- 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),
- PC>
- PC>
HTTP協議的驗證如圖-8所示:
圖-8
從輸入結果能夠驗證,PC1到Web Server的http訪問沒有受到影響,但不能ping通192.168.4.1。
步驟五:在PC2上進行驗證
- PC>ipconfig
- FastEthernet0 Connection:(default port)
- Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
- IP Address......................: 192.168.1.2
- Subnet Mask.....................: 255.255.255.0
- Default Gateway.................: 192.168.0.1
- 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=126
- Reply from 192.168.4.1: bytes=32 time=0ms TTL=126
- Reply from 192.168.4.1: bytes=32 time=0ms TTL=126
- Reply from 192.168.4.1: bytes=32 time=0ms TTL=126
- 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 = 0ms, Average = 0ms
- PC>
HTTP協議的驗證,如圖-9所示: