HSRPSTPACL

1 HSRP配置 ? ?

1.1 問題

在企業網絡到外部的連接方案中,要求不高的條件下可以是單出口。一旦該出口線路出現問題,整個企業網絡就不能連接到外網了。為了使得企業網絡到外網連接的高可用性,可以設置兩個以上的出口,然而多個出口對于內網主機意味著我個網關。主機不能同時使用多個網關,當主機所使用的網關出現故障時,它不能實現網關的自動切換。

1)配置熱備份路由協議

1.2 方案

在出口設備上配置熱備份路由協議(HSRP),組成一個HSRP組,組內兩個出口設備共享一個虛擬IP地址,該IP地址作為內網主機的網關。

HSRP組成員有主備之分,虛擬IP地址被附加到主設備上。如果主設備線路出故障,備份設備會成為主設備,虛擬IP地址也會遷移過來。這樣,不管哪一個出口設備出現問題,不管哪個出口設備在提供外網接入,內網主機的網關都不需要改變。

網絡拓撲圖如圖-1所示:

圖-1

?

?

藍色區域表示內網,上面模擬到外網的連接。

1.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:分別在三臺路由器上配置端口IP地址

  1. tarena-R1(config)#int f0/0
  2. tarena-R1(config-if)#ip address 192.168.0.1 255.255.255.0
  3. tarena-R1(config-if)#no shutdown
  4. tarena-R1(config-if)#interface f0/1
  5. tarena-R1(config-if)#ip address 192.168.1.1 255.255.255.0
  6. tarena-R1(config-if)#no shutdown
  7. tarena-R2(config)#interface f0/0
  8. tarena-R2(config-if)#ip address 192.168.0.2 255.255.255.0
  9. tarena-R2(config-if)#no shutdown
  10. tarena-R2(config-if)#interface f0/1
  11. tarena-R2(config-if)#ip address 192.168.2.1 255.255.255.0
  12. tarena-R2(config-if)#no shutdown
  13. tarena-R3(config)#interface f0/0
  14. tarena-R3(config-if)#ip address 192.168.1.2 255.255.255.0
  15. tarena-R3(config-if)#no shutdown
  16. tarena-R3(config-if)#interface f0/1
  17. tarena-R3(config-if)#ip address 192.168.2.2 255.255.255.0
  18. tarena-R3(config-if)#no shutdown
  19. tarena-R3(config-if)#interface f1/0
  20. tarena-R3(config-if)#ip address 200.1.1.1 255.255.255.0
  21. tarena-R3(config-if)#no shutdown

步驟二:在R1和R2上配置到外網的默認路由

  1. tarena-R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.2
  2. tarena-R1(config)#end
  3. tarena-R1#show ip route
  4. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  5. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  6. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  7. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  8. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  9. * - candidate default, U - per-user static route, o - ODR
  10. P - periodic downloaded static route
  11. Gateway of last resort is 192.168.1.2 to network 0.0.0.0
  12. C 192.168.0.0/24 is directly connected, FastEthernet0/0
  13. C 192.168.1.0/24 is directly connected, FastEthernet0/1
  14. S* 0.0.0.0/0 [1/0] via 192.168.1.2
  15. tarena-R1#
  16. tarena-R2(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2
  17. tarena-R2(config)#exit
  18. tarena-R2#show ip route
  19. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  20. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  21. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  22. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  23. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  24. * - candidate default, U - per-user static route, o - ODR
  25. P - periodic downloaded static route
  26. Gateway of last resort is 192.168.2.2 to network 0.0.0.0
  27. C 192.168.0.0/24 is directly connected, FastEthernet0/0
  28. C 192.168.2.0/24 is directly connected, FastEthernet0/1
  29. S* 0.0.0.0/0 [1/0] via 192.168.2.2

步驟三:在R3上配置到企業內網的靜態路由

  1. tarena-R3(config)#ip route 192.168.0.0 255.255.255.0 192.168.2.1
  2. tarena-R3(config)#ip route 192.168.0.0 255.255.255.0 192.168.1.1
  3. tarena-R3(config)#end
  4. tarena-R3#show ip route
  5. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  6. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  7. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  8. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  9. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  10. * - candidate default, U - per-user static route, o - ODR
  11. P - periodic downloaded static route
  12. Gateway of last resort is not set
  13. S 192.168.0.0/24 [1/0] via 192.168.2.1
  14. [1/0] via 192.168.1.1
  15. C 192.168.1.0/24 is directly connected, FastEthernet0/0
  16. C 192.168.2.0/24 is directly connected, FastEthernet0/1
  17. C 200.1.1.0/24 is directly connected, FastEthernet1/0
  18. tarena-R3#

步驟四:在R1上配置HSRP,指定其優先級為200

HSRP的默認優先級為100,路由器啟動后,根據優先級決定誰可以成為活躍路由器,優先級高的將勝出。如果路由器優先級相同,再比較端口IP地址,IP地址大的成為活路躍路由器。

另外,如果優先級低的路由器先啟動了,它將成為活躍路由器。優先級高的路由器啟動后,發現已有活躍路由器存在,它將接受現狀,直到活躍路由器出現故障它才會在重新選舉時成為活躍角色。

  1. tarena-R1(config)#interface f0/0
  2. tarena-R1(config-if)#standby 1 ip 192.168.0.254
  3. tarena-R1(config-if)#standby 1 priority 200
  4. %HSRP-6-STATECHANGE: FastEthernet0/0 Grp 1 state Speak -> Standby
  5. %HSRP-6-STATECHANGE: FastEthernet0/0 Grp 1 state Standby -> Active

配置HSRP后,通過輸出日志可以觀察到路由器角色的改變。

步驟五:在R2上配置HSRP,指定其優先級為195

  1. tarena-R2(config)#interface f0/0
  2. tarena-R2(config-if)#standby 1 ip 192.168.0.254
  3. tarena-R2(config-if)#standby 1 priority 195
  4. %HSRP-6-STATECHANGE: FastEthernet0/0 Grp 1 state Speak -> Standby

步驟六:分別在R1和R2上查看HSRP信息

  1. tarena-R1#show standby brief
  2. P indicates configured to preempt.
  3. |
  4. Interface Grp Pri P State Active Standby Virtual IP
  5. Fa0/0 1 200 Active local 192.168.0.2 192.168.0.254
  6. tarena-R2#show standby brief
  7. P indicates configured to preempt.
  8. |
  9. Interface Grp Pri P State Active Standby Virtual IP
  10. Fa0/0 1 195 Standby 192.168.0.1 local 192.168.0.254

根據輸出信息,可以看到優先級大的R1成為了活躍路由器,繼續在其上面查看arp信息,能夠查看到虛擬IP地址被附加到R1上了。

  1. tarena-R1#show ip arp
  2. Protocol Address Age (min) Hardware Addr Type Interface
  3. Internet 192.168.0.1 - 0005.5E53.3001 ARPA FastEthernet0/0
  4. Internet 192.168.0.254 12 0000.0C9F.F001 ARPA FastEthernet0/0
  5. Internet 192.168.1.1 - 0005.5E53.3002 ARPA FastEthernet0/1

步驟七:在內部主機上測試到外網主機的連通性

  1. PC>ipconfig
  2. FastEthernet0 Connection:(default port)
  3. Link-local IPv6 Address.........: FE80::207:ECFF:FE80:557D
  4. IP Address......................: 192.168.0.10
  5. Subnet Mask.....................: 255.255.255.0
  6. Default Gateway.................: 192.168.0.254
  7. PC>ping 200.1.1.10
  8. Pinging 200.1.1.10 with 32 bytes of data:
  9. Reply from 200.1.1.10: bytes=32 time=0ms TTL=126
  10. Reply from 200.1.1.10: bytes=32 time=0ms TTL=126
  11. Reply from 200.1.1.10: bytes=32 time=0ms TTL=126
  12. Reply from 200.1.1.10: bytes=32 time=1ms TTL=126
  13. Ping statistics for 200.1.1.10:
  14. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  15. Approximate round trip times in milli-seconds:
  16. Minimum = 0ms, Maximum = 1ms, Average = 0ms
  17. PC>tracert 200.1.1.10
  18. Tracing route to 200.1.1.10 over a maximum of 30 hops:
  19. 1 0 ms 1 ms 0 ms 192.168.0.1
  20. 2 0 ms 1 ms 0 ms 192.168.1.2
  21. 3 0 ms 0 ms 0 ms 200.1.1.10
  22. Trace complete.
  23. PC>

Ping命令只能檢測網絡是否連通,如果要查看具體路徑需要使用tracert。根據tracert顯示結果,R1轉發了PC機的數據包。

步驟八:關閉R1電源,模擬設備故障,查看R2的HSRP信息

  1. tarena-R2#
  2. %HSRP-6-STATECHANGE: FastEthernet0/0 Grp 1 state Standby -> Active
  3. tarena-R2#show standby brief
  4. P indicates configured to preempt.
  5. |
  6. Interface Grp Pri P State Active Standby Virtual IP
  7. Fa0/0 1 195 Active local unknown 192.168.0.254
  8. tarena-R2#show ip arp
  9. Protocol Address Age (min) Hardware Addr Type Interface
  10. Internet 192.168.0.2 - 0001.4200.9C01 ARPA FastEthernet0/0
  11. Internet 192.168.0.10 9 0007.EC80.557D ARPA FastEthernet0/0
  12. Internet 192.168.0.254 1 0000.0C9F.F001 ARPA FastEthernet0/0
  13. Internet 192.168.2.1 - 0001.4200.9C02 ARPA FastEthernet0/1
  14. Internet 192.168.2.2 9 0005.5E59.E002 ARPA FastEthernet0/1

結果顯示R2已成為活躍路由器,而備份路由器狀態未知。虛擬路由器的IP地址192.168.0.254/24也已遷移到R2上了。

步驟九:再次在內部主機上測試到外網主機的連通性

  1. PC>ping 200.1.1.10
  2. Pinging 200.1.1.10 with 32 bytes of data:
  3. Reply from 200.1.1.10: bytes=32 time=0ms TTL=126
  4. Reply from 200.1.1.10: bytes=32 time=1ms TTL=126
  5. Reply from 200.1.1.10: bytes=32 time=1ms TTL=126
  6. Reply from 200.1.1.10: bytes=32 time=0ms TTL=126
  7. Ping statistics for 200.1.1.10:
  8. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  9. Approximate round trip times in milli-seconds:
  10. Minimum = 0ms, Maximum = 1ms, Average = 0ms
  11. PC>tracert 200.1.1.10
  12. Tracing route to 200.1.1.10 over a maximum of 30 hops:
  13. 1 1 ms 0 ms 0 ms 192.168.0.2
  14. 2 0 ms 0 ms 0 ms 192.168.2.2
  15. 3 0 ms 1 ms 0 ms 200.1.1.10
  16. Trace complete.
  17. PC>

根據tracert結果,路由器R2轉發了PC機的數據包

步驟十:再次在內部主機上測試到外網主機的連通性

備份路由器成為活躍路由器后,原來的活躍路由器R1即使線路修復也不會重新成為進入活躍狀態。

為了使路由器完全根據優先級來決定其狀態,需要配置占先權。占先權保證了嚴格根據優先級來決定哪臺設備進入活躍狀態。

  1. tarena-R1(config)#interface f0/0
  2. tarena-R1(config-if)#standby 1 preempt
  3. tarena-R2(config)#interface f0/0
  4. tarena-R2(config-if)#standby 1 preempt

2 PVST+的配置

2.1 問題

二層網絡中有可能出現因為線路故障而導致的通信故障,通過冗余線路可以消除因為某一線路故障而導致的網絡中斷。

但是因為冗余線路的存在,又可能會出現廣播風暴、相同幀的不斷復制和MAC地址表不穩定。

1)配置Switch1為vlan1的主根,Switch2為vlan1的次根

2.2 方案

為了保證在冗余環境下不會出廣播風暴等問題,引入了生成樹(STP)協議。通過生成樹協議可以把冗余線路上的某一個端口置為阻塞(BLOCKING)狀態,防止廣播風暴的產生,當某一線路出現故障時,被阻塞的端口自動進入轉發(FORWARDING)狀態,保證網絡的暢通性。

網絡拓撲如圖-2所示:

圖-2

?

?

?

2.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:將三臺交換機相連的端口配置為中繼端口

  1. tarena-sw1(config)#interface range f0/12 -13
  2. tarena-sw1(config-if-range)#switchport mode trunk
  3. tarena-sw2(config)#interface range f0/12, f0/23
  4. tarena-sw2(config-if-range)#switchport mode trunk
  5. tarena-sw3(config)#interface range f0/13 ,f0/23
  6. tarena-sw3(config-if-range)#switchport mode trunk

步驟二:設置tarena-sw1為根網橋

根網橋唯一的依據是BID最小。BID分為兩個部分:優先級+MAC地址。比較BID時,先比較優先級,如果優先級相同才比較MAC地址。

優先級取值范圍是0到65535,默認值為32768。在查看優先級時,即使是默認值看到的也不是32768,因為交換機的優先級采用系統優先級+VLAN編號的方式,所以查看到的VLAN1默認優先級是32769(系統優先級32768+VLAN編號1)。

  1. tarena-sw1(config)#spanning-tree vlan 1 root primary
  2. tarena-sw1(config)#exit
  3. tarena-sw1#show spanning-tree
  4. VLAN0001
  5. Spanning tree enabled protocol ieee
  6. Root ID Priority 24577 //默認優先級為32768
  7. Address 0060.478B.607B
  8. This bridge is the root
  9. Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  10. Bridge ID Priority 24577 (priority 24576 sys-id-ext 1)
  11. Address 0060.478B.607B
  12. Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  13. Aging Time 20
  14. Interface Role Sts Cost Prio.Nbr Type
  15. ----------- ------ --- -------- -------- ----------------------
  16. Fa0/13 Desg FWD 19 128.13 P2p
  17. Fa0/12 Desg FWD 19 128.12 P2p

查看到的結果,Root ID部分指的是根網橋信息,Bridge ID部分是當前所操作的交換機信息,如果二者一致表示當前操作的交換機就是根網橋。

步驟三:設置tarena-sw2為次根,即BID值大小居中

  1. tarena-sw2(config)#spanning-tree vlan 1 root secondary
  2. tarena-sw2#show spanning-tree
  3. VLAN0001
  4. Spanning tree enabled protocol ieee
  5. Root ID Priority 24577 //此處雖然與tarena-sw1一樣,但MAC地址更大
  6. Address 0060.478B.607B
  7. Cost 19
  8. Port 12(FastEthernet0/12)
  9. Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  10. Bridge ID Priority 28673 (priority 28672 sys-id-ext 1)
  11. Address 0090.0C77.8924
  12. Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  13. Aging Time 20
  14. Interface Role Sts Cost Prio.Nbr Type
  15. ---------- ---- ---- ----- -------- ---------
  16. Fa0/12 Root FWD 19 128.12 P2p
  17. Fa0/23 Desg FWD 19 128.23 P2p

步驟四:tarena-sw3不需要做改動,直接查看STP狀態

  1. tarena-sw3#show spanning-tree
  2. VLAN0001
  3. Spanning tree enabled protocol ieee
  4. Root ID Priority 24577
  5. Address 0060.478B.607B
  6. Cost 19
  7. Port 13(FastEthernet0/13)
  8. Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  9. Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
  10. Address 0060.5C9E.2E75
  11. Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  12. Aging Time 20
  13. Interface Role Sts Cost Prio.Nbr Type
  14. ---------- ------ ---- ----- -------- ----------
  15. Fa0/13 Root FWD 19 128.13 P2p
  16. Fa0/23 Altn BLK 19 128.23 P2p

觀察Sts列(即狀態status),Fa0/23端口當前是耳塞(BLK)狀態,即該端口不能轉發數據。

步驟五:模擬交換機間線纜故障。將tarena-sw2的Fa0/12口shutdown,再次檢查tarena-sw3端口狀態

  1. tarena-sw2(config)#interface f0/12
  2. tarena-sw2(config-if)#shutdown
  3. tarena-sw3#show spanning-tree
  4. VLAN0001
  5. Spanning tree enabled protocol ieee
  6. Root ID Priority 24577
  7. Address 0060.478B.607B
  8. Cost 19
  9. Port 13(FastEthernet0/13)
  10. Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  11. Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
  12. Address 0060.5C9E.2E75
  13. Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  14. Aging Time 20
  15. Interface Role Sts Cost Prio.Nbr Type
  16. ---------- ------ ---- ----- -------- ----------
  17. Fa0/13 Root FWD 19 128.13 P2p
  18. Fa0/23 Desg FWD 19 128.23 P2p

從tarena-sw3的輸出可以看到,Fa0/23端口已從阻塞狀態切換到轉發(FWD)狀態,保證了網絡的暢通。當線路恢復(在rarena-sw2的Fa0/12端口執行no shutdown)后,tarena-sw3的Fa0/23端口將重新進入阻塞狀態以網止環路的產生。

在查看時,tarena-sw3的Fa0/23端口不是立即進入轉發或是阻塞狀態。生成樹端口有阻塞,偵聽,學習和轉發四個狀態,當拓撲變化時,端口狀態改變要遵從這些狀態的逐漸改變。

?

1 配置標準ACL

1.1 問題

絡調通后,保證網絡是通暢的。同時也很可能出現未經授權的非法訪問。企業網絡既要解決連連通的問題,還要解決網絡安全的問題。

1)配置標準ACL實現拒絕PC2(IP地址為192.168.0.20)對Web Server P的瀏覽器訪問

1.2 方案

訪問控制是網絡安全防范和保護的主要策略,它的主要任務是保證網絡資源不被非法使用和訪問。它是保證網絡安全最重要的核心策略之一。

訪問控制列表(Access Control Lists,ACL)是應用在路由器接口的指令列表。這些指令列表用來告訴路由器哪能些數據包可以收、哪能數據包需要拒絕。至于數據包是被接收還是拒絕,可以由類似于源地址、目的地址、端口號等的特定指示條件來決定。

標準訪問控制列表只能根據數據包的源IP地址決定是否允許通過。

網絡拓撲如圖-1所示:

圖-1

?

1.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:在R1上配置IP地址及靜態路由

  1. tarena-R1(config)#interface f0/0
  2. tarena-R1(config-if)#ip address 192.168.0.1 255.255.255.0
  3. tarena-R1(config-if)#no shutdown
  4. tarena-R1(config-if)#interface f0/1
  5. tarena-R1(config-if)#ip address 192.168.1.1 255.255.255.0
  6. tarena-R1(config-if)#no shutdown
  7. tarena-R1(config-if)#exit
  8. tarena-R1(config)#ip route 192.168.2.0 255.255.255.0 192.168.1.2

步驟二:在R2上配置IP地址及靜態路由

  1. tarena-R2(config)#interface f0/0
  2. tarena-R2(config-if)#ip address 192.168.1.2 255.255.255.0
  3. tarena-R2(config-if)#no shutdown
  4. tarena-R2(config-if)#interface f0/1
  5. tarena-R2(config-if)#ip address 192.168.2.1 255.255.255.0
  6. tarena-R2(config-if)#no shutdown
  7. tarena-R2(config-if)#exit
  8. tarena-R2(config)#ip route 192.168.0.0 255.255.255.0 192.168.1.1

步驟三:在R1和R2上檢查路由表

  1. tarena-R1#show ip route
  2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  3. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  4. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  5. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  6. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  7. * - candidate default, U - per-user static route, o - ODR
  8. P - periodic downloaded static route
  9. Gateway of last resort is not set
  10. C 192.168.0.0/24 is directly connected, FastEthernet0/0
  11. C 192.168.1.0/24 is directly connected, FastEthernet0/1
  12. S 192.168.2.0/24 [1/0] via 192.168.1.2
  13. tarena-R2#
  14. tarena-R2#show ip route
  15. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  16. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  17. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  18. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  19. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  20. * - candidate default, U - per-user static route, o - ODR
  21. P - periodic downloaded static route
  22. Gateway of last resort is not set
  23. S 192.168.0.0/24 [1/0] via 192.168.1.1
  24. C 192.168.1.0/24 is directly connected, FastEthernet0/0
  25. C 192.168.2.0/24 is directly connected, FastEthernet0/1

步驟四:測試主機到Web Server的連通性

在實施ACL之前先檢查網絡是否能夠正常通信,因為沒有任何限制,網絡應該是處于連通狀態。

PC1測試如下所示:

  1. PC>ipconfig
  2. FastEthernet0 Connection:(default port)
  3. Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
  4. IP Address......................: 192.168.0.10
  5. Subnet Mask.....................: 255.255.255.0
  6. Default Gateway.................: 192.168.0.1
  7. PC>ping 192.168.2.100
  8. Pinging 192.168.2.100 with 32 bytes of data:
  9. Request timed out.
  10. Request timed out.
  11. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  12. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  13. Ping statistics for 192.168.2.100:
  14. Packets: Sent = 4, Received = 2, Lost = 2 (50% loss),
  15. Approximate round trip times in milli-seconds:
  16. Minimum = 0ms, Maximum = 0ms, Average = 0ms
  17. PC>

PC2測試如下所示:

  1. PC>ipconfig
  2. FastEthernet0 Connection:(default port)
  3. Link-local IPv6 Address.........: FE80::2D0:BAFF:FE98:9E29
  4. IP Address......................: 192.168.0.20
  5. Subnet Mask.....................: 255.255.255.0
  6. Default Gateway.................: 192.168.0.1
  7. PC>ping 192.168.2.100
  8. Pinging 192.168.2.100 with 32 bytes of data:
  9. Reply from 192.168.2.100: bytes=32 time=2ms TTL=126
  10. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  11. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  12. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  13. Ping statistics for 192.168.2.100:
  14. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  15. Approximate round trip times in milli-seconds:
  16. Minimum = 0ms, Maximum = 2ms, Average = 0ms
  17. PC>

步驟五:在R2上配置標準訪問控制列表,并應用到Fa0/1端口出方向上

標準訪問控制列表因為只能限制源IP地址,因此應該把ACL放到離目標最近的端口出方向上。

ACL的匹配規則中,最后有一條隱含拒絕全部。如果語句中全部是拒絕條目,那么最后必須存在允許語句,否則所有數據通信都將被拒絕。

  1. tarena-R2(config)#access-list 1 deny host 192.168.0.20
  2. tarena-R2(config)#access-list 1 permit any
  3. tarena-R2(config)#interface f0/1
  4. tarena-R2(config-if)#ip access-group 1 out

步驟六:分別在兩臺主機上測試到Web Server的連通性

PC1測試如下所示:

  1. PC>ipconfig
  2. FastEthernet0 Connection:(default port)
  3. Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
  4. IP Address......................: 192.168.0.10
  5. Subnet Mask.....................: 255.255.255.0
  6. Default Gateway.................: 192.168.0.1
  7. PC>ping 192.168.2.100
  8. Pinging 192.168.2.100 with 32 bytes of data:
  9. Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  10. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  11. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  12. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  13. Ping statistics for 192.168.2.100:
  14. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  15. Approximate round trip times in milli-seconds:
  16. Minimum = 0ms, Maximum = 1ms, Average = 0ms
  17. PC>

PC2測試如下所示:

  1. PC>ipconfig
  2. FastEthernet0 Connection:(default port)
  3. Link-local IPv6 Address.........: FE80::2D0:BAFF:FE98:9E29
  4. IP Address......................: 192.168.0.20
  5. Subnet Mask.....................: 255.255.255.0
  6. Default Gateway.................: 192.168.0.1
  7. PC>ping 192.168.2.100
  8. Pinging 192.168.2.100 with 32 bytes of data:
  9. Reply from 192.168.1.2: Destination host unreachable.
  10. Reply from 192.168.1.2: Destination host unreachable.
  11. Reply from 192.168.1.2: Destination host unreachable.
  12. Reply from 192.168.1.2: Destination host unreachable.
  13. Ping statistics for 192.168.2.100:
  14. Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
  15. PC>

結果顯示PC1(IP地址為192.168.0.10)可以正常訪問Web Server,而PC2(IP地址為192.168.0.20)已經被192.168.1.2(R2)拒絕。

步驟七:在R2上查看相關的ACL信息

  1. tarena-R2#show ip access-lists
  2. Standard IP access list 1
  3. deny host 192.168.0.20 (4 match(es))
  4. permit any (4 match(es))

?

2 配置擴展ACL

2.1 問題

在網絡中很有可能要允許或拒絕的并不是某一個源IP地址,而是根據目標地址或是協議來匹配。但是標準訪問控制列表只能根據源IP地址來決定是否允許一個數據包通過。

1)配置擴展ACL實現拒絕PC2(IP地址為192.168.0.20)訪問Web Server的web服務,但可訪問其他服務。

2.2 方案

為了實現更靈活、列精確的網絡控制就需要用到擴展訪問控制列表了。

擴展IP訪問控制列表比標準IP訪問控制列表具有更多的匹配項,包括協議類型、源地址、目的地址、源端口、目的端口、建立連接的和IP優先級等。

網絡拓撲如圖-2所示:

圖-2

?

2.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:將1配置標準ACL中的標準訪問控制列表移除,其他配置保留

  1. tarena-R2(config)#interface f0/1
  2. tarena-R2(config-if)#no ip access-group 1 out
  3. tarena-R2(config)#no access-list 1

步驟二:在PC1和PC2上驗證到Web Server的HTTP協議訪問,如圖3和圖-4所示:

圖-3

?

圖-4

?

在沒有配置擴展ACL的時候,兩臺主機均可以正常訪問到Web Server。

步驟三:R1上配置擴展訪問控制列表,僅拒絕PC2到Web Server的HTTP訪問

擴展ACL可以對數據包中的源、目標IP地址以及端口號進行檢查,所以可以將該ACL放置在通信路徑中的任一位置。但是,如果放到離目標近的地方,每臺路由器都要對數據進行處理,會更多的消耗路由器和帶寬資源。放到離源最近的路由器端口入方向直接就將拒絕數據丟棄,可以減少其他路由器的資源占用以及帶寬占用。

  1. tarena-R1(config)#access-list 100 deny tcp host 192.168.0.20 host 192.168.2.100 eq www
  2. tarena-R1(config)#access-list 100 permit ip any any
  3. tarena-R1(config)#interface f0/0
  4. tarena-R1(config-if)#ip access-group 101 in

步驟四:在PC1上驗證

  1. PC>ipconfig
  2. FastEthernet0 Connection:(default port)
  3. Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
  4. IP Address......................: 192.168.0.10
  5. Subnet Mask.....................: 255.255.255.0
  6. Default Gateway.................: 192.168.0.1
  7. PC>ping 192.168.2.100
  8. Pinging 192.168.2.100 with 32 bytes of data:
  9. Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  10. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  11. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  12. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  13. Ping statistics for 192.168.2.100:
  14. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  15. Approximate round trip times in milli-seconds:
  16. Minimum = 0ms, Maximum = 1ms, Average = 0ms
  17. PC>

HTTP協議的驗證如圖-5所示:

圖-5

?

從輸入結果可以驗證,PC1到Web Server的訪問沒有受到任何影響。

步驟五:在PC2上進行驗證

  1. PC>ipconfig
  2. FastEthernet0 Connection:(default port)
  3. Link-local IPv6 Address.........: FE80::2D0:BAFF:FE98:9E29
  4. IP Address......................: 192.168.0.20
  5. Subnet Mask.....................: 255.255.255.0
  6. Default Gateway.................: 192.168.0.1
  7. PC>ping 192.168.2.100
  8. Pinging 192.168.2.100 with 32 bytes of data:
  9. Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  10. Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  11. Reply from 192.168.2.100: bytes=32 time=2ms TTL=126
  12. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  13. Ping statistics for 192.168.2.100:
  14. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  15. Approximate round trip times in milli-seconds:
  16. Minimum = 0ms, Maximum = 2ms, Average = 1ms
  17. PC>

HTTP協議的驗證,如圖-6所示:

圖-6

?

因為只限制了到Web Server的HTTP訪問,所以WEB服務已經無法訪問,但是仍然可以ping通。

步驟六:在R1上查看相關的ACL信息

  1. tarena-R1#show ip access-lists
  2. Extended IP access list 100
  3. deny tcp host 192.168.0.20 host 192.168.2.100 eq www (30 match(es))
  4. permit ip any any (5 match(es))

路由器的輸出表明了拒絕了30個來自PC1到Web Server的HTTP訪問包。

3 配置標準命名ACL

3.1 問題

使用基本編號的ACL沒有實際意義,只有通過閱讀具體的條目才能得知該ACL的作用。而且ACL的編號有限制,如傳統的標準ACL用1~99表示,擴展ACL用100~199表示。

1)配置標準命名ACL實現拒絕PC2(IP地址為192.168.0.20)對Web Server的訪問

3.2 方案

命名訪問控制列表可以為ACL起一個有意義的名字,通過名稱就可以得知該ACL要實現什么功能。同時,因為使用的是名稱而不是數字,也就沒有了ACL數量上的限制。

網絡拓撲如圖-7所示:

圖-7

?

3.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:將2配置擴展ACL中的擴展訪問控制列表移除,其他配置保留

  1. tarena-R1(config)#interface f0/0
  2. tarena-R1(config-if)#no ip access-group 100 in
  3. tarena-R1(config-if)#exit
  4. tarena-R1(config)#no access-list 100

步驟二:在R2上配置標準的命名訪問控制列表

命名訪問控制列表的配置總體上和用數字表示的ACL一樣,但是更加靈活。

  1. tarena-R2(config)#ip access-list standard denypc2
  2. tarena-R2(config-std-nacl)#deny host 192.168.0.20
  3. tarena-R2(config-std-nacl)#permit any
  4. tarena-R2(config-std-nacl)#exit
  5. tarena-R2(config)#interface f0/1
  6. tarena-R2(config-if)#ip access-group denypc2 out

步驟三:分別在PC1和PC2上做連通性測試

PC1測試如下所示:

  1. PC>ipconfig
  2. FastEthernet0 Connection:(default port)
  3. Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
  4. IP Address......................: 192.168.0.10
  5. Subnet Mask.....................: 255.255.255.0
  6. Default Gateway.................: 192.168.0.1
  7. PC>ping 192.168.2.100
  8. Pinging 192.168.2.100 with 32 bytes of data:
  9. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  10. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  11. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  12. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  13. Ping statistics for 192.168.2.100:
  14. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  15. Approximate round trip times in milli-seconds:
  16. Minimum = 0ms, Maximum = 0ms, Average = 0ms
  17. PC>

PC2測試如下所示:

  1. PC>ipconfig
  2. FastEthernet0 Connection:(default port)
  3. Link-local IPv6 Address.........: FE80::2D0:BAFF:FE98:9E29
  4. IP Address......................: 192.168.0.20
  5. Subnet Mask.....................: 255.255.255.0
  6. Default Gateway.................: 192.168.0.1
  7. PC>ping 192.168.2.100
  8. Pinging 192.168.2.100 with 32 bytes of data:
  9. Reply from 192.168.1.2: Destination host unreachable.
  10. Reply from 192.168.1.2: Destination host unreachable.
  11. Reply from 192.168.1.2: Destination host unreachable.
  12. Reply from 192.168.1.2: Destination host unreachable.
  13. Ping statistics for 192.168.2.100:
  14. Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
  15. PC>

輸出結果表明,PC1的訪問是正常的,而PC2到Web Server的訪問被R2(IP地址為192.168.1.2)拒絕。

步驟四:在R2上查看相關的ACL信息

  1. tarena-R2#show ip access-lists
  2. Standard IP access list denypc2
  3. 10 deny host 192.168.0.20 (4 match(es))
  4. 20 permit any (4 match(es))

輸出結果也表明,來自于PC2的數據包被攔截。

4 配置擴展命名ACL

4.1 問題

使用基本編號的ACL沒有實際意義,只有通過閱讀具體的條目才能得知該ACL的作用。而且ACL的編號有限制,如傳統的標準ACL用1~99表示,擴展ACL用100~199表示。

1)配置擴展命名ACL實現拒絕PC2(IP地址為192.168.0.20)訪問Web Server Web服務,但可訪問其他服務。

4.2 方案

命名訪問控制列表可以為ACL起一個有意義的名字,通過名稱就可以得知該ACL要實現什么功能。同時,因為使用的是名稱而不是數字,也就沒有了ACL數量上的限制。

網絡拓撲如圖-8所示:

圖-8

?

4.3 步驟

實現此案例需要按照如下步驟進行。

步驟一:將3配置標準命名ACL中的標準命名訪問控制列表移除,其他配置保留

  1. tarena-R2(config)#interface f0/1
  2. tarena-R2(config-if)#no ip access-group denypc2 out
  3. tarena-R2(config-if)#exit
  4. tarena-R2(config)# no ip access-list standard denypc2

步驟二:在R2上配置擴展命名訪問控制列表

命名訪問控制列表的配置總體上和用數字表示的ACL一樣,但是更加靈活。

  1. tarena-R2(config)#ip access-list extended denypc2
  2. tarena-R2(config-ext-nacl)#deny tcp host 192.168.0.20 host 192.168.2.100 eq www
  3. tarena-R2(config-ext-nacl)#permit ip any any
  4. tarena-R2(config)#interface fastEthernet 0/1
  5. tarena-R2(config-if)#ip access-group denypc2 out

步驟三:在R2上查看相關的ACL信息

  1. tarena-R2#show access-lists
  2. Extended IP access list denypc2
  3. 10 deny tcp host 192.168.0.20 host 192.168.2.100 eq www
  4. 20 permit ip any any

步驟四:在PC1上驗證

  1. PC>ipconfig
  2. FastEthernet0 Connection:(default port)
  3. Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
  4. IP Address......................: 192.168.0.10
  5. Subnet Mask.....................: 255.255.255.0
  6. Default Gateway.................: 192.168.0.1
  7. PC>ping 192.168.2.100
  8. Pinging 192.168.2.100 with 32 bytes of data:
  9. Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  10. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  11. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  12. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  13. Ping statistics for 192.168.2.100:
  14. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  15. Approximate round trip times in milli-seconds:
  16. Minimum = 0ms, Maximum = 1ms, Average = 0ms
  17. PC>

HTTP協議的驗證如圖-9所示:

圖-9

?

從輸入結果可以驗證,PC1到Web Server的訪問沒有受到任何影響。

步驟五:在PC2上進行驗證

  1. PC>ipconfig
  2. FastEthernet0 Connection:(default port)
  3. Link-local IPv6 Address.........: FE80::2D0:BAFF:FE98:9E29
  4. IP Address......................: 192.168.0.20
  5. Subnet Mask.....................: 255.255.255.0
  6. Default Gateway.................: 192.168.0.1
  7. PC>ping 192.168.2.100
  8. Pinging 192.168.2.100 with 32 bytes of data:
  9. Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  10. Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  11. Reply from 192.168.2.100: bytes=32 time=2ms TTL=126
  12. Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  13. Ping statistics for 192.168.2.100:
  14. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  15. Approximate round trip times in milli-seconds:
  16. Minimum = 0ms, Maximum = 2ms, Average = 1ms
  17. PC>

HTTP協議的驗證,如圖-10所示:

圖-10

?

因為只限制了到Web Server的HTTP訪問,所以WEB服務已經無法訪問,但是仍然可以ping通。

轉載于:https://www.cnblogs.com/fyy-hhzzj/p/8306048.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/252487.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/252487.shtml
英文地址,請注明出處:http://en.pswp.cn/news/252487.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

java 的 CopyOnWriteArrayList類

初識CopyOnWriteArrayList 第一次見到CopyOnWriteArrayList,是在研究JDBC的時候,每一個數據庫的Driver都是維護在一個CopyOnWriteArrayList中的,為了證明這一點,貼兩段代碼,第一段在com.mysql.jdbc.Driver下&#xff0…

科技的趨勢!AI將進軍了37%的企業

2019獨角獸企業重金招聘Python工程師標準>>> 市場研究機構Gartner調查了全球89個國家的逾3,000名信息長(CIO),顯示有37%的企業已經或打算于近期內部署人工智能(AI),在4年內成長270%。Gartner研究…

CMakeLists.txt編寫規則

在PROJECT_SOURCE_DIR下新建了src, include, lib, bin四個子文件夾。 src文件夾用來存放所有的.cpp文件,include文件夾用來存儲所有的.h文件, lib中存放生成的自己編寫的共享庫, bin中存放所有的可執行文件 用SET來設置.exe可執行文件和共享…

nginx.conf配置詳解

######Nginx配置文件nginx.conf中文詳解######定義Nginx運行的用戶和用戶組 user www www;#nginx進程數,建議設置為等于CPU總核心數。 worker_processes 8;#全局錯誤日志定義類型,[ debug | info | notice | warn | error | crit ] error_log /usr/local…

更新 hadoop eclipse 插件

卸載hadoop 1.1.2插件。并安裝新版hadoop 2.2.0插件。 假設直接刪除eclipse plugin文件夾下的hadoop 1.1.2插件,會導致hadoop 1.1.2插件殘留在eclipse中,在eclipse perspective視圖中有Map/Reduce視圖,可是沒有圖標,新建項目也不會…

【K8S學習筆記】Part1:使用端口轉發訪問集群內的應用

本文介紹如何使用kubectl port-forward命令連接K8S集群中運行的Redis服務。這種連接方式有助于數據庫的調試工作。 注意:本文針對K8S的版本號為v1.9,其他版本可能會有少許不同。 0x00 準備工作 在進行該操作之前,需要滿足以下條件&#xff1a…

Ubuntu 16.04 桌面菜單欄 任務欄 標題欄消失的解決辦法

將home目錄下的.cache刪除掉就可以了 & cd & sudo rm -r ./.cache

瓜子二手車發12月二手車價格:漢蘭達奧德賽CR-V保值率居首

中新網1月22日電 日前,基于海量個人對個人的二手車成交數據,瓜子二手車公布了12月全國及多個核心城市的二手車交易“瓜子價”數據。數據顯示,2018年12月全國瓜子二手車嚴選直賣簽約均價為87934元,環比上漲0.16%,同比上…

概率分布之間的距離度量以及python實現(三)

概率分布之間的距離,顧名思義,度量兩組樣本分布之間的距離 。 1、卡方檢驗 統計學上的χ2統計量,由于它最初是由英國統計學家Karl Pearson在1900年首次提出的,因此也稱之為Pearson χ2,其計算公式為 (i1,2&…

Windows vs Linux:\r\n 與 \r

Linux 下文本文件的換行符為 \nWindows 下文本文件的換行符為 \r\n,占兩個字節: \r:歸位鍵(CR),ascii 碼為 13\n:換行鍵(LF),ascii 碼位 10也即單行無換行文本…

C++求職題

文章大部分內容轉載https://www.cnblogs.com/lanxuezaipiao/p/4127904.html 1.冒泡排序法: 如果有N個數字需要排序,那么需要進行(N-1)趟循環,第i趟循環需要對比的次數為(N-i)。所以可以用雙重循環,外層循環用于控制循環的趟數&a…

Python-爬蟲-requests

簡介 #介紹:使用requests可以模擬瀏覽器的請求,比起之前用到的urllib,requests模塊的api更加便捷(本質就是封裝了urllib3)#注意:requests庫發送請求將網頁內容下載下來以后,并不會執行js代碼&am…

JS如何監聽動畫結束

場景描述 在使用JS控制動畫時一般需要在動畫結束后執行回調去進行DOM的相關操作,所以需要監聽動畫結束進行回調。JS提供了以下事件用于監聽動畫的結束,簡單總結學習下。 CSS3動畫監聽事件 transitionEnd事件 transitionEnd事件會在CSS transition動畫結束…

封裝一個ViewPager真正的實現圖片無限循環滾動帶導航點

效果圖: 大家在寫項目的過程中常常會碰到須要實現Viewpager里面載入幾張圖片來循環自己主動輪播的效果,假設不封裝一下的話代碼分散在activity里面會顯得非常亂。并且也不利于我們下次復用,所以這里我把viewpager的相關代碼抽取出來放在了一個…

畢業論文頁眉頁腳頁碼插入

用word這么多年,第一次完整的操作了一遍頁眉頁腳頁碼的插入過程,其實三者都要要求奇偶頁不同 1.頁面布局-》右下角箭頭-》版式-》奇偶頁不同 因為文章不同的部分需要插入不同的頁眉頁腳頁碼,所以要在不同的部分插入分解符斷開它們的連接 2、…

巴黎市中心降下2019年第一場雪

當地時間1月22日,法國巴黎市中心降下2019年第一場雪,氣溫也隨之下降,街上的行人和車輛均有所減少。中新社記者 李洋 攝一對情侶在埃菲爾鐵塔前合影留念。無家可歸者在長椅上睡覺。游客在盧浮宮前拍照。

Echarts實現隱藏x軸,y軸,刻度線,網格

"yAxis": [{//就是一月份這個顯示為一個線段,而不是數軸那種一個點點"show" : true,"boundaryGap": true,"type": "category","name": "時間","data": ["1月", "2…

Ubuntu16.04 + Matlab2018+ desktop creation

https://blog.csdn.net/m0_37601622/article/details/82731879 https://blog.csdn.net/l18092482025/article/details/78906436 The second blog teaches you how to download a matlab.png when there is no matlab.png in /usr/share/applications/.

Atom插件主題推薦

注意事項 主題和插件這方面,比 Sublime Text 人性化多了..一些比較用心的作者增加了二度設置功能。 何為二度設置,就是不用手寫代碼修改配置文件,點點鼠標,填填輸入框就能生效,主題以 isotope-ui 這個做例子介紹,看圖: 進入二度設…

印尼發生洪災和山體滑坡 致多人死亡數千人撤離

當地時間1月23日,印尼南蘇拉威西省望加錫居民受洪水影像,用竹筏運送摩托車。近日,印尼南蘇拉威西省暴雨連連,造成洪災和山體滑坡。目前,暴雨引發的洪災和山體滑坡至少已造成8人死亡,數千人被迫撤離家園。。…