一、配置標准ACL
目標:
絡調通后,保證網絡是通暢的。同時也很可能出現未經授權的非法訪問。企業網絡既要解決連連通的問題,還要解決網絡安全的問題。
- 配置標准ACL實現拒絕PC1(IP地址為192.168.1.1)對外問網絡192.168.2.1的訪問
方案:
訪問控制是網絡安全防范和保護的主要策略,它的主要任務是保證網絡資源不被非法使用和訪問。它是保證網絡安全最重要的核心策略之一。
訪問控制列表(Access Control Lists,ACL)是應用在路由器接口的指令列表。這些指令列表用來告訴路由器哪能些數據包可以收、哪能數據包需要拒絕。至於數據包是被接收還是拒絕,可以由類似於源地址、目的地址、端口號等的特定指示條件來決定。
標准訪問控制列表只能根據數據包的源IP地址決定是否允許通過。
網絡拓撲如下圖所示:
步驟:
步驟一:在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之前先檢查網絡是否能夠正常通信,因為沒有任何限制,網絡應該是處於連通狀態。
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)
二、配置擴展ACL
目標:
在網絡中很有可能要允許或拒絕的並不是某一個源IP地址,而是根據目標地址或是協議來匹配。但是標准訪問控制列表只能根據源IP地址來決定是否允許一個數據包通過。
配置擴展ACL允許pc1訪問pc4的www服務但拒絕訪問PC4的其他服務,PC2、PC3無限制。
方案:
為了實現更靈活、列精確的網絡控制就需要用到擴展訪問控制列表了。
擴展IP訪問控制列表比標准IP訪問控制列表具有更多的匹配項,包括協議類型、源地址、目的地址、源端口、目的端口、建立連接的和IP優先級等。
網絡拓撲如下圖所示:
步驟:
步驟一:在三台路由器中配置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服務后在PC1、PC2和PC3上驗證到Web Server的HTTP協議訪問,均如下圖所示:
在沒有配置擴展ACL的時候,主機均可以正常訪問到Web Server。
步驟三: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
步驟四:在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協議的驗證如下圖所示:
從輸入結果可以驗證,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協議的驗證,如下圖所示:
步驟六:在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))
三、配置標准命名ACL
目標:
使用基本編號的ACL沒有實際意義,只有通過閱讀具體的條目才能得知該ACL的作用。而且ACL的編號有限制,如傳統的標准ACL用1~99表示,擴展ACL用100~199表示。
- 配置標准命名ACL實現192.168.1.0網段拒絕PC1訪問外部網絡,其他主機無限制。
方案:
命名訪問控制列表可以為ACL起一個有意義的名字,通過名稱就可以得知該ACL要實現什么功能。同時,因為使用的是名稱而不是數字,也就沒有了ACL數量上的限制。
網絡拓撲如下圖所示:
步驟:
步驟一:將案例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的數據包被攔截。
四、配置擴展命名ACL
目標:
使用基本編號的ACL沒有實際意義,只有通過閱讀具體的條目才能得知該ACL的作用。而且ACL的編號有限制,如傳統的標准ACL用1~99表示,擴展ACL用100~199表示。
- 配置擴展命名ACL允許PC1訪問192.168.4.1的www服務但拒絕訪問192.168.4.1的其他服務,PC2、PC3無限制。
方案:
命名訪問控制列表可以為ACL起一個有意義的名字,通過名稱就可以得知該ACL要實現什么功能。同時,因為使用的是名稱而不是數字,也就沒有了ACL數量上的限制。
網絡拓撲如下圖所示:
步驟:
步驟一:將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協議的驗證如下圖所示:
從輸入結果可以驗證,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協議的驗證,如下圖所示: