日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

HSRPSTPACL

發(fā)布時(shí)間:2023/12/13 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HSRPSTPACL 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1 HSRP配置 ? ?

1.1 問(wèn)題

在企業(yè)網(wǎng)絡(luò)到外部的連接方案中,要求不高的條件下可以是單出口。一旦該出口線路出現(xiàn)問(wèn)題,整個(gè)企業(yè)網(wǎng)絡(luò)就不能連接到外網(wǎng)了。為了使得企業(yè)網(wǎng)絡(luò)到外網(wǎng)連接的高可用性,可以設(shè)置兩個(gè)以上的出口,然而多個(gè)出口對(duì)于內(nèi)網(wǎng)主機(jī)意味著我個(gè)網(wǎng)關(guān)。主機(jī)不能同時(shí)使用多個(gè)網(wǎng)關(guān),當(dāng)主機(jī)所使用的網(wǎng)關(guān)出現(xiàn)故障時(shí),它不能實(shí)現(xiàn)網(wǎng)關(guān)的自動(dòng)切換。

1)配置熱備份路由協(xié)議

1.2 方案

在出口設(shè)備上配置熱備份路由協(xié)議(HSRP),組成一個(gè)HSRP組,組內(nèi)兩個(gè)出口設(shè)備共享一個(gè)虛擬IP地址,該IP地址作為內(nèi)網(wǎng)主機(jī)的網(wǎng)關(guān)。

HSRP組成員有主備之分,虛擬IP地址被附加到主設(shè)備上。如果主設(shè)備線路出故障,備份設(shè)備會(huì)成為主設(shè)備,虛擬IP地址也會(huì)遷移過(guò)來(lái)。這樣,不管哪一個(gè)出口設(shè)備出現(xiàn)問(wèn)題,不管哪個(gè)出口設(shè)備在提供外網(wǎng)接入,內(nèi)網(wǎng)主機(jī)的網(wǎng)關(guān)都不需要改變。

網(wǎng)絡(luò)拓?fù)鋱D如圖-1所示:

圖-1

?

?

藍(lán)色區(qū)域表示內(nèi)網(wǎng),上面模擬到外網(wǎng)的連接。

1.3 步驟

實(shí)現(xiàn)此案例需要按照如下步驟進(jìn)行。

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

  • tarena-R1(config)#int f0/0
  • tarena-R1(config-if)#ip address 192.168.0.1 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.1.1 255.255.255.0
  • tarena-R1(config-if)#no shutdown
  • tarena-R2(config)#interface f0/0
  • tarena-R2(config-if)#ip address 192.168.0.2 255.255.255.0
  • tarena-R2(config-if)#no shutdown
  • tarena-R2(config-if)#interface f0/1
  • tarena-R2(config-if)#ip address 192.168.2.1 255.255.255.0
  • tarena-R2(config-if)#no shutdown
  • tarena-R3(config)#interface f0/0
  • tarena-R3(config-if)#ip address 192.168.1.2 255.255.255.0
  • tarena-R3(config-if)#no shutdown
  • tarena-R3(config-if)#interface f0/1
  • tarena-R3(config-if)#ip address 192.168.2.2 255.255.255.0
  • tarena-R3(config-if)#no shutdown
  • tarena-R3(config-if)#interface f1/0
  • tarena-R3(config-if)#ip address 200.1.1.1 255.255.255.0
  • tarena-R3(config-if)#no shutdown
  • 步驟二:在R1和R2上配置到外網(wǎng)的默認(rèn)路由

  • tarena-R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.2
  • tarena-R1(config)#end
  • tarena-R1#show ip route
  • Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  • D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  • N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  • E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  • i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  • * - candidate default, U - per-user static route, o - ODR
  • P - periodic downloaded static route
  • Gateway of last resort is 192.168.1.2 to network 0.0.0.0
  • C 192.168.0.0/24 is directly connected, FastEthernet0/0
  • C 192.168.1.0/24 is directly connected, FastEthernet0/1
  • S* 0.0.0.0/0 [1/0] via 192.168.1.2
  • tarena-R1#
  • tarena-R2(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2
  • tarena-R2(config)#exit
  • tarena-R2#show ip route
  • Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  • D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  • N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  • E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  • i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  • * - candidate default, U - per-user static route, o - ODR
  • P - periodic downloaded static route
  • Gateway of last resort is 192.168.2.2 to network 0.0.0.0
  • C 192.168.0.0/24 is directly connected, FastEthernet0/0
  • C 192.168.2.0/24 is directly connected, FastEthernet0/1
  • S* 0.0.0.0/0 [1/0] via 192.168.2.2
  • 步驟三:在R3上配置到企業(yè)內(nèi)網(wǎng)的靜態(tài)路由

  • tarena-R3(config)#ip route 192.168.0.0 255.255.255.0 192.168.2.1
  • tarena-R3(config)#ip route 192.168.0.0 255.255.255.0 192.168.1.1
  • tarena-R3(config)#end
  • tarena-R3#show ip route
  • Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  • D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  • N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  • E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  • i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  • * - candidate default, U - per-user static route, o - ODR
  • P - periodic downloaded static route
  • Gateway of last resort is not set
  • S 192.168.0.0/24 [1/0] via 192.168.2.1
  • [1/0] via 192.168.1.1
  • C 192.168.1.0/24 is directly connected, FastEthernet0/0
  • C 192.168.2.0/24 is directly connected, FastEthernet0/1
  • C 200.1.1.0/24 is directly connected, FastEthernet1/0
  • tarena-R3#
  • 步驟四:在R1上配置HSRP,指定其優(yōu)先級(jí)為200

    HSRP的默認(rèn)優(yōu)先級(jí)為100,路由器啟動(dòng)后,根據(jù)優(yōu)先級(jí)決定誰(shuí)可以成為活躍路由器,優(yōu)先級(jí)高的將勝出。如果路由器優(yōu)先級(jí)相同,再比較端口IP地址,IP地址大的成為活路躍路由器。

    另外,如果優(yōu)先級(jí)低的路由器先啟動(dòng)了,它將成為活躍路由器。優(yōu)先級(jí)高的路由器啟動(dòng)后,發(fā)現(xiàn)已有活躍路由器存在,它將接受現(xiàn)狀,直到活躍路由器出現(xiàn)故障它才會(huì)在重新選舉時(shí)成為活躍角色。

  • tarena-R1(config)#interface f0/0
  • tarena-R1(config-if)#standby 1 ip 192.168.0.254
  • tarena-R1(config-if)#standby 1 priority 200
  • %HSRP-6-STATECHANGE: FastEthernet0/0 Grp 1 state Speak -> Standby
  • %HSRP-6-STATECHANGE: FastEthernet0/0 Grp 1 state Standby -> Active
  • 配置HSRP后,通過(guò)輸出日志可以觀察到路由器角色的改變。

    步驟五:在R2上配置HSRP,指定其優(yōu)先級(jí)為195

  • tarena-R2(config)#interface f0/0
  • tarena-R2(config-if)#standby 1 ip 192.168.0.254
  • tarena-R2(config-if)#standby 1 priority 195
  • %HSRP-6-STATECHANGE: FastEthernet0/0 Grp 1 state Speak -> Standby
  • 步驟六:分別在R1和R2上查看HSRP信息

  • tarena-R1#show standby brief
  • P indicates configured to preempt.
  • |
  • Interface Grp Pri P State Active Standby Virtual IP
  • Fa0/0 1 200 Active local 192.168.0.2 192.168.0.254
  • tarena-R2#show standby brief
  • P indicates configured to preempt.
  • |
  • Interface Grp Pri P State Active Standby Virtual IP
  • Fa0/0 1 195 Standby 192.168.0.1 local 192.168.0.254
  • 根據(jù)輸出信息,可以看到優(yōu)先級(jí)大的R1成為了活躍路由器,繼續(xù)在其上面查看arp信息,能夠查看到虛擬IP地址被附加到R1上了。

  • tarena-R1#show ip arp
  • Protocol Address Age (min) Hardware Addr Type Interface
  • Internet 192.168.0.1 - 0005.5E53.3001 ARPA FastEthernet0/0
  • Internet 192.168.0.254 12 0000.0C9F.F001 ARPA FastEthernet0/0
  • Internet 192.168.1.1 - 0005.5E53.3002 ARPA FastEthernet0/1
  • 步驟七:在內(nèi)部主機(jī)上測(cè)試到外網(wǎng)主機(jī)的連通性

  • PC>ipconfig
  • FastEthernet0 Connection:(default port)
  • Link-local IPv6 Address.........: FE80::207:ECFF:FE80:557D
  • IP Address......................: 192.168.0.10
  • Subnet Mask.....................: 255.255.255.0
  • Default Gateway.................: 192.168.0.254
  • PC>ping 200.1.1.10
  • Pinging 200.1.1.10 with 32 bytes of data:
  • Reply from 200.1.1.10: bytes=32 time=0ms TTL=126
  • Reply from 200.1.1.10: bytes=32 time=0ms TTL=126
  • Reply from 200.1.1.10: bytes=32 time=0ms TTL=126
  • Reply from 200.1.1.10: bytes=32 time=1ms TTL=126
  • Ping statistics for 200.1.1.10:
  • Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  • Approximate round trip times in milli-seconds:
  • Minimum = 0ms, Maximum = 1ms, Average = 0ms
  • PC>tracert 200.1.1.10
  • Tracing route to 200.1.1.10 over a maximum of 30 hops:
  • 1 0 ms 1 ms 0 ms 192.168.0.1
  • 2 0 ms 1 ms 0 ms 192.168.1.2
  • 3 0 ms 0 ms 0 ms 200.1.1.10
  • Trace complete.
  • PC>
  • Ping命令只能檢測(cè)網(wǎng)絡(luò)是否連通,如果要查看具體路徑需要使用tracert。根據(jù)tracert顯示結(jié)果,R1轉(zhuǎn)發(fā)了PC機(jī)的數(shù)據(jù)包。

    步驟八:關(guān)閉R1電源,模擬設(shè)備故障,查看R2的HSRP信息

  • tarena-R2#
  • %HSRP-6-STATECHANGE: FastEthernet0/0 Grp 1 state Standby -> Active
  • tarena-R2#show standby brief
  • P indicates configured to preempt.
  • |
  • Interface Grp Pri P State Active Standby Virtual IP
  • Fa0/0 1 195 Active local unknown 192.168.0.254
  • tarena-R2#show ip arp
  • Protocol Address Age (min) Hardware Addr Type Interface
  • Internet 192.168.0.2 - 0001.4200.9C01 ARPA FastEthernet0/0
  • Internet 192.168.0.10 9 0007.EC80.557D ARPA FastEthernet0/0
  • Internet 192.168.0.254 1 0000.0C9F.F001 ARPA FastEthernet0/0
  • Internet 192.168.2.1 - 0001.4200.9C02 ARPA FastEthernet0/1
  • Internet 192.168.2.2 9 0005.5E59.E002 ARPA FastEthernet0/1
  • 結(jié)果顯示R2已成為活躍路由器,而備份路由器狀態(tài)未知。虛擬路由器的IP地址192.168.0.254/24也已遷移到R2上了。

    步驟九:再次在內(nèi)部主機(jī)上測(cè)試到外網(wǎng)主機(jī)的連通性

  • PC>ping 200.1.1.10
  • Pinging 200.1.1.10 with 32 bytes of data:
  • Reply from 200.1.1.10: bytes=32 time=0ms TTL=126
  • Reply from 200.1.1.10: bytes=32 time=1ms TTL=126
  • Reply from 200.1.1.10: bytes=32 time=1ms TTL=126
  • Reply from 200.1.1.10: bytes=32 time=0ms TTL=126
  • Ping statistics for 200.1.1.10:
  • Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  • Approximate round trip times in milli-seconds:
  • Minimum = 0ms, Maximum = 1ms, Average = 0ms
  • PC>tracert 200.1.1.10
  • Tracing route to 200.1.1.10 over a maximum of 30 hops:
  • 1 1 ms 0 ms 0 ms 192.168.0.2
  • 2 0 ms 0 ms 0 ms 192.168.2.2
  • 3 0 ms 1 ms 0 ms 200.1.1.10
  • Trace complete.
  • PC>
  • 根據(jù)tracert結(jié)果,路由器R2轉(zhuǎn)發(fā)了PC機(jī)的數(shù)據(jù)包

    步驟十:再次在內(nèi)部主機(jī)上測(cè)試到外網(wǎng)主機(jī)的連通性

    備份路由器成為活躍路由器后,原來(lái)的活躍路由器R1即使線路修復(fù)也不會(huì)重新成為進(jìn)入活躍狀態(tài)。

    為了使路由器完全根據(jù)優(yōu)先級(jí)來(lái)決定其狀態(tài),需要配置占先權(quán)。占先權(quán)保證了嚴(yán)格根據(jù)優(yōu)先級(jí)來(lái)決定哪臺(tái)設(shè)備進(jìn)入活躍狀態(tài)。

  • tarena-R1(config)#interface f0/0
  • tarena-R1(config-if)#standby 1 preempt
  • tarena-R2(config)#interface f0/0
  • tarena-R2(config-if)#standby 1 preempt
  • 2 PVST+的配置

    2.1 問(wèn)題

    二層網(wǎng)絡(luò)中有可能出現(xiàn)因?yàn)榫€路故障而導(dǎo)致的通信故障,通過(guò)冗余線路可以消除因?yàn)槟骋痪€路故障而導(dǎo)致的網(wǎng)絡(luò)中斷。

    但是因?yàn)槿哂嗑€路的存在,又可能會(huì)出現(xiàn)廣播風(fēng)暴、相同幀的不斷復(fù)制和MAC地址表不穩(wěn)定。

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

    2.2 方案

    為了保證在冗余環(huán)境下不會(huì)出廣播風(fēng)暴等問(wèn)題,引入了生成樹(shù)(STP)協(xié)議。通過(guò)生成樹(shù)協(xié)議可以把冗余線路上的某一個(gè)端口置為阻塞(BLOCKING)狀態(tài),防止廣播風(fēng)暴的產(chǎn)生,當(dāng)某一線路出現(xiàn)故障時(shí),被阻塞的端口自動(dòng)進(jìn)入轉(zhuǎn)發(fā)(FORWARDING)狀態(tài),保證網(wǎng)絡(luò)的暢通性。

    網(wǎng)絡(luò)拓?fù)淙鐖D-2所示:

    圖-2

    ?

    ?

    ?

    2.3 步驟

    實(shí)現(xiàn)此案例需要按照如下步驟進(jìn)行。

    步驟一:將三臺(tái)交換機(jī)相連的端口配置為中繼端口

  • tarena-sw1(config)#interface range f0/12 -13
  • tarena-sw1(config-if-range)#switchport mode trunk
  • tarena-sw2(config)#interface range f0/12, f0/23
  • tarena-sw2(config-if-range)#switchport mode trunk
  • tarena-sw3(config)#interface range f0/13 ,f0/23
  • tarena-sw3(config-if-range)#switchport mode trunk
  • 步驟二:設(shè)置tarena-sw1為根網(wǎng)橋

    根網(wǎng)橋唯一的依據(jù)是BID最小。BID分為兩個(gè)部分:優(yōu)先級(jí)+MAC地址。比較BID時(shí),先比較優(yōu)先級(jí),如果優(yōu)先級(jí)相同才比較MAC地址。

    優(yōu)先級(jí)取值范圍是0到65535,默認(rèn)值為32768。在查看優(yōu)先級(jí)時(shí),即使是默認(rèn)值看到的也不是32768,因?yàn)榻粨Q機(jī)的優(yōu)先級(jí)采用系統(tǒng)優(yōu)先級(jí)+VLAN編號(hào)的方式,所以查看到的VLAN1默認(rèn)優(yōu)先級(jí)是32769(系統(tǒng)優(yōu)先級(jí)32768+VLAN編號(hào)1)。

  • tarena-sw1(config)#spanning-tree vlan 1 root primary
  • tarena-sw1(config)#exit
  • tarena-sw1#show spanning-tree
  • VLAN0001
  • Spanning tree enabled protocol ieee
  • Root ID Priority 24577 //默認(rèn)優(yōu)先級(jí)為32768
  • Address 0060.478B.607B
  • This bridge is the root
  • Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  • Bridge ID Priority 24577 (priority 24576 sys-id-ext 1)
  • Address 0060.478B.607B
  • Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  • Aging Time 20
  • Interface Role Sts Cost Prio.Nbr Type
  • ----------- ------ --- -------- -------- ----------------------
  • Fa0/13 Desg FWD 19 128.13 P2p
  • Fa0/12 Desg FWD 19 128.12 P2p
  • 查看到的結(jié)果,Root ID部分指的是根網(wǎng)橋信息,Bridge ID部分是當(dāng)前所操作的交換機(jī)信息,如果二者一致表示當(dāng)前操作的交換機(jī)就是根網(wǎng)橋。

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

  • tarena-sw2(config)#spanning-tree vlan 1 root secondary
  • tarena-sw2#show spanning-tree
  • VLAN0001
  • Spanning tree enabled protocol ieee
  • Root ID Priority 24577 //此處雖然與tarena-sw1一樣,但MAC地址更大
  • Address 0060.478B.607B
  • Cost 19
  • Port 12(FastEthernet0/12)
  • Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  • Bridge ID Priority 28673 (priority 28672 sys-id-ext 1)
  • Address 0090.0C77.8924
  • Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  • Aging Time 20
  • Interface Role Sts Cost Prio.Nbr Type
  • ---------- ---- ---- ----- -------- ---------
  • Fa0/12 Root FWD 19 128.12 P2p
  • Fa0/23 Desg FWD 19 128.23 P2p
  • 步驟四:tarena-sw3不需要做改動(dòng),直接查看STP狀態(tài)

  • tarena-sw3#show spanning-tree
  • VLAN0001
  • Spanning tree enabled protocol ieee
  • Root ID Priority 24577
  • Address 0060.478B.607B
  • Cost 19
  • Port 13(FastEthernet0/13)
  • Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  • Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
  • Address 0060.5C9E.2E75
  • Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  • Aging Time 20
  • Interface Role Sts Cost Prio.Nbr Type
  • ---------- ------ ---- ----- -------- ----------
  • Fa0/13 Root FWD 19 128.13 P2p
  • Fa0/23 Altn BLK 19 128.23 P2p
  • 觀察Sts列(即狀態(tài)status),Fa0/23端口當(dāng)前是耳塞(BLK)狀態(tài),即該端口不能轉(zhuǎn)發(fā)數(shù)據(jù)。

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

  • tarena-sw2(config)#interface f0/12
  • tarena-sw2(config-if)#shutdown
  • tarena-sw3#show spanning-tree
  • VLAN0001
  • Spanning tree enabled protocol ieee
  • Root ID Priority 24577
  • Address 0060.478B.607B
  • Cost 19
  • Port 13(FastEthernet0/13)
  • Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  • Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
  • Address 0060.5C9E.2E75
  • Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
  • Aging Time 20
  • Interface Role Sts Cost Prio.Nbr Type
  • ---------- ------ ---- ----- -------- ----------
  • Fa0/13 Root FWD 19 128.13 P2p
  • Fa0/23 Desg FWD 19 128.23 P2p
  • 從tarena-sw3的輸出可以看到,Fa0/23端口已從阻塞狀態(tài)切換到轉(zhuǎn)發(fā)(FWD)狀態(tài),保證了網(wǎng)絡(luò)的暢通。當(dāng)線路恢復(fù)(在rarena-sw2的Fa0/12端口執(zhí)行no shutdown)后,tarena-sw3的Fa0/23端口將重新進(jìn)入阻塞狀態(tài)以網(wǎng)止環(huán)路的產(chǎn)生。

    在查看時(shí),tarena-sw3的Fa0/23端口不是立即進(jìn)入轉(zhuǎn)發(fā)或是阻塞狀態(tài)。生成樹(shù)端口有阻塞,偵聽(tīng),學(xué)習(xí)和轉(zhuǎn)發(fā)四個(gè)狀態(tài),當(dāng)拓?fù)渥兓瘯r(shí),端口狀態(tài)改變要遵從這些狀態(tài)的逐漸改變。

    ?

    1 配置標(biāo)準(zhǔn)ACL

    1.1 問(wèn)題

    絡(luò)調(diào)通后,保證網(wǎng)絡(luò)是通暢的。同時(shí)也很可能出現(xiàn)未經(jīng)授權(quán)的非法訪問(wèn)。企業(yè)網(wǎng)絡(luò)既要解決連連通的問(wèn)題,還要解決網(wǎng)絡(luò)安全的問(wèn)題。

    1)配置標(biāo)準(zhǔn)ACL實(shí)現(xiàn)拒絕PC2(IP地址為192.168.0.20)對(duì)Web Server P的瀏覽器訪問(wèn)

    1.2 方案

    訪問(wèn)控制是網(wǎng)絡(luò)安全防范和保護(hù)的主要策略,它的主要任務(wù)是保證網(wǎng)絡(luò)資源不被非法使用和訪問(wèn)。它是保證網(wǎng)絡(luò)安全最重要的核心策略之一。

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

    標(biāo)準(zhǔn)訪問(wèn)控制列表只能根據(jù)數(shù)據(jù)包的源IP地址決定是否允許通過(guò)。

    網(wǎng)絡(luò)拓?fù)淙鐖D-1所示:

    圖-1

    ?

    1.3 步驟

    實(shí)現(xiàn)此案例需要按照如下步驟進(jìn)行。

    步驟一:在R1上配置IP地址及靜態(tài)路由

  • tarena-R1(config)#interface f0/0
  • tarena-R1(config-if)#ip address 192.168.0.1 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.1.1 255.255.255.0
  • tarena-R1(config-if)#no shutdown
  • tarena-R1(config-if)#exit
  • tarena-R1(config)#ip route 192.168.2.0 255.255.255.0 192.168.1.2
  • 步驟二:在R2上配置IP地址及靜態(tài)路由

  • tarena-R2(config)#interface f0/0
  • tarena-R2(config-if)#ip address 192.168.1.2 255.255.255.0
  • tarena-R2(config-if)#no shutdown
  • tarena-R2(config-if)#interface f0/1
  • tarena-R2(config-if)#ip address 192.168.2.1 255.255.255.0
  • tarena-R2(config-if)#no shutdown
  • tarena-R2(config-if)#exit
  • tarena-R2(config)#ip route 192.168.0.0 255.255.255.0 192.168.1.1
  • 步驟三:在R1和R2上檢查路由表

  • tarena-R1#show ip route
  • Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  • D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  • N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  • E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  • i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  • * - candidate default, U - per-user static route, o - ODR
  • P - periodic downloaded static route
  • Gateway of last resort is not set
  • C 192.168.0.0/24 is directly connected, FastEthernet0/0
  • C 192.168.1.0/24 is directly connected, FastEthernet0/1
  • S 192.168.2.0/24 [1/0] via 192.168.1.2
  • tarena-R2#
  • tarena-R2#show ip route
  • Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  • D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  • N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  • E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  • i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  • * - candidate default, U - per-user static route, o - ODR
  • P - periodic downloaded static route
  • Gateway of last resort is not set
  • S 192.168.0.0/24 [1/0] via 192.168.1.1
  • C 192.168.1.0/24 is directly connected, FastEthernet0/0
  • C 192.168.2.0/24 is directly connected, FastEthernet0/1
  • 步驟四:測(cè)試主機(jī)到Web Server的連通性

    在實(shí)施ACL之前先檢查網(wǎng)絡(luò)是否能夠正常通信,因?yàn)闆](méi)有任何限制,網(wǎng)絡(luò)應(yīng)該是處于連通狀態(tài)。

    PC1測(cè)試如下所示:

  • PC>ipconfig
  • FastEthernet0 Connection:(default port)
  • Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
  • IP Address......................: 192.168.0.10
  • Subnet Mask.....................: 255.255.255.0
  • Default Gateway.................: 192.168.0.1
  • PC>ping 192.168.2.100
  • Pinging 192.168.2.100 with 32 bytes of data:
  • Request timed out.
  • Request timed out.
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Ping statistics for 192.168.2.100:
  • Packets: Sent = 4, Received = 2, Lost = 2 (50% loss),
  • Approximate round trip times in milli-seconds:
  • Minimum = 0ms, Maximum = 0ms, Average = 0ms
  • PC>
  • PC2測(cè)試如下所示:

  • PC>ipconfig
  • FastEthernet0 Connection:(default port)
  • Link-local IPv6 Address.........: FE80::2D0:BAFF:FE98:9E29
  • IP Address......................: 192.168.0.20
  • Subnet Mask.....................: 255.255.255.0
  • Default Gateway.................: 192.168.0.1
  • PC>ping 192.168.2.100
  • Pinging 192.168.2.100 with 32 bytes of data:
  • Reply from 192.168.2.100: bytes=32 time=2ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Ping statistics for 192.168.2.100:
  • Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  • Approximate round trip times in milli-seconds:
  • Minimum = 0ms, Maximum = 2ms, Average = 0ms
  • PC>
  • 步驟五:在R2上配置標(biāo)準(zhǔn)訪問(wèn)控制列表,并應(yīng)用到Fa0/1端口出方向上

    標(biāo)準(zhǔn)訪問(wèn)控制列表因?yàn)橹荒芟拗圃碔P地址,因此應(yīng)該把ACL放到離目標(biāo)最近的端口出方向上。

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

  • tarena-R2(config)#access-list 1 deny host 192.168.0.20
  • tarena-R2(config)#access-list 1 permit any
  • tarena-R2(config)#interface f0/1
  • tarena-R2(config-if)#ip access-group 1 out
  • 步驟六:分別在兩臺(tái)主機(jī)上測(cè)試到Web Server的連通性

    PC1測(cè)試如下所示:

  • PC>ipconfig
  • FastEthernet0 Connection:(default port)
  • Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
  • IP Address......................: 192.168.0.10
  • Subnet Mask.....................: 255.255.255.0
  • Default Gateway.................: 192.168.0.1
  • PC>ping 192.168.2.100
  • Pinging 192.168.2.100 with 32 bytes of data:
  • Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Ping statistics for 192.168.2.100:
  • Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  • Approximate round trip times in milli-seconds:
  • Minimum = 0ms, Maximum = 1ms, Average = 0ms
  • PC>
  • PC2測(cè)試如下所示:

  • PC>ipconfig
  • FastEthernet0 Connection:(default port)
  • Link-local IPv6 Address.........: FE80::2D0:BAFF:FE98:9E29
  • IP Address......................: 192.168.0.20
  • Subnet Mask.....................: 255.255.255.0
  • Default Gateway.................: 192.168.0.1
  • PC>ping 192.168.2.100
  • Pinging 192.168.2.100 with 32 bytes of data:
  • Reply from 192.168.1.2: Destination host unreachable.
  • Reply from 192.168.1.2: Destination host unreachable.
  • Reply from 192.168.1.2: Destination host unreachable.
  • Reply from 192.168.1.2: Destination host unreachable.
  • Ping statistics for 192.168.2.100:
  • Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
  • PC>
  • 結(jié)果顯示PC1(IP地址為192.168.0.10)可以正常訪問(wèn)Web Server,而PC2(IP地址為192.168.0.20)已經(jīng)被192.168.1.2(R2)拒絕。

    步驟七:在R2上查看相關(guān)的ACL信息

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

    2 配置擴(kuò)展ACL

    2.1 問(wèn)題

    在網(wǎng)絡(luò)中很有可能要允許或拒絕的并不是某一個(gè)源IP地址,而是根據(jù)目標(biāo)地址或是協(xié)議來(lái)匹配。但是標(biāo)準(zhǔn)訪問(wèn)控制列表只能根據(jù)源IP地址來(lái)決定是否允許一個(gè)數(shù)據(jù)包通過(guò)。

    1)配置擴(kuò)展ACL實(shí)現(xiàn)拒絕PC2(IP地址為192.168.0.20)訪問(wèn)Web Server的web服務(wù),但可訪問(wèn)其他服務(wù)。

    2.2 方案

    為了實(shí)現(xiàn)更靈活、列精確的網(wǎng)絡(luò)控制就需要用到擴(kuò)展訪問(wèn)控制列表了。

    擴(kuò)展IP訪問(wèn)控制列表比標(biāo)準(zhǔn)IP訪問(wèn)控制列表具有更多的匹配項(xiàng),包括協(xié)議類(lèi)型、源地址、目的地址、源端口、目的端口、建立連接的和IP優(yōu)先級(jí)等。

    網(wǎng)絡(luò)拓?fù)淙鐖D-2所示:

    圖-2

    ?

    2.3 步驟

    實(shí)現(xiàn)此案例需要按照如下步驟進(jìn)行。

    步驟一:將1配置標(biāo)準(zhǔn)ACL中的標(biāo)準(zhǔn)訪問(wèn)控制列表移除,其他配置保留

  • tarena-R2(config)#interface f0/1
  • tarena-R2(config-if)#no ip access-group 1 out
  • tarena-R2(config)#no access-list 1
  • 步驟二:在PC1和PC2上驗(yàn)證到Web Server的HTTP協(xié)議訪問(wèn),如圖3和圖-4所示:

    圖-3

    ?

    圖-4

    ?

    在沒(méi)有配置擴(kuò)展ACL的時(shí)候,兩臺(tái)主機(jī)均可以正常訪問(wèn)到Web Server。

    步驟三:R1上配置擴(kuò)展訪問(wèn)控制列表,僅拒絕PC2到Web Server的HTTP訪問(wèn)

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

  • tarena-R1(config)#access-list 100 deny tcp host 192.168.0.20 host 192.168.2.100 eq www
  • tarena-R1(config)#access-list 100 permit ip any any
  • tarena-R1(config)#interface f0/0
  • tarena-R1(config-if)#ip access-group 101 in
  • 步驟四:在PC1上驗(yàn)證

  • PC>ipconfig
  • FastEthernet0 Connection:(default port)
  • Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
  • IP Address......................: 192.168.0.10
  • Subnet Mask.....................: 255.255.255.0
  • Default Gateway.................: 192.168.0.1
  • PC>ping 192.168.2.100
  • Pinging 192.168.2.100 with 32 bytes of data:
  • Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Ping statistics for 192.168.2.100:
  • Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  • Approximate round trip times in milli-seconds:
  • Minimum = 0ms, Maximum = 1ms, Average = 0ms
  • PC>
  • HTTP協(xié)議的驗(yàn)證如圖-5所示:

    圖-5

    ?

    從輸入結(jié)果可以驗(yàn)證,PC1到Web Server的訪問(wèn)沒(méi)有受到任何影響。

    步驟五:在PC2上進(jìn)行驗(yàn)證

  • PC>ipconfig
  • FastEthernet0 Connection:(default port)
  • Link-local IPv6 Address.........: FE80::2D0:BAFF:FE98:9E29
  • IP Address......................: 192.168.0.20
  • Subnet Mask.....................: 255.255.255.0
  • Default Gateway.................: 192.168.0.1
  • PC>ping 192.168.2.100
  • Pinging 192.168.2.100 with 32 bytes of data:
  • Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=2ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Ping statistics for 192.168.2.100:
  • Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  • Approximate round trip times in milli-seconds:
  • Minimum = 0ms, Maximum = 2ms, Average = 1ms
  • PC>
  • HTTP協(xié)議的驗(yàn)證,如圖-6所示:

    圖-6

    ?

    因?yàn)橹幌拗屏说絎eb Server的HTTP訪問(wèn),所以WEB服務(wù)已經(jīng)無(wú)法訪問(wèn),但是仍然可以ping通。

    步驟六:在R1上查看相關(guān)的ACL信息

  • tarena-R1#show ip access-lists
  • Extended IP access list 100
  • deny tcp host 192.168.0.20 host 192.168.2.100 eq www (30 match(es))
  • permit ip any any (5 match(es))
  • 路由器的輸出表明了拒絕了30個(gè)來(lái)自PC1到Web Server的HTTP訪問(wèn)包。

    3 配置標(biāo)準(zhǔn)命名ACL

    3.1 問(wèn)題

    使用基本編號(hào)的ACL沒(méi)有實(shí)際意義,只有通過(guò)閱讀具體的條目才能得知該ACL的作用。而且ACL的編號(hào)有限制,如傳統(tǒng)的標(biāo)準(zhǔn)ACL用1~99表示,擴(kuò)展ACL用100~199表示。

    1)配置標(biāo)準(zhǔn)命名ACL實(shí)現(xiàn)拒絕PC2(IP地址為192.168.0.20)對(duì)Web Server的訪問(wèn)

    3.2 方案

    命名訪問(wèn)控制列表可以為ACL起一個(gè)有意義的名字,通過(guò)名稱(chēng)就可以得知該ACL要實(shí)現(xiàn)什么功能。同時(shí),因?yàn)槭褂玫氖敲Q(chēng)而不是數(shù)字,也就沒(méi)有了ACL數(shù)量上的限制。

    網(wǎng)絡(luò)拓?fù)淙鐖D-7所示:

    圖-7

    ?

    3.3 步驟

    實(shí)現(xiàn)此案例需要按照如下步驟進(jìn)行。

    步驟一:將2配置擴(kuò)展ACL中的擴(kuò)展訪問(wèn)控制列表移除,其他配置保留

  • tarena-R1(config)#interface f0/0
  • tarena-R1(config-if)#no ip access-group 100 in
  • tarena-R1(config-if)#exit
  • tarena-R1(config)#no access-list 100
  • 步驟二:在R2上配置標(biāo)準(zhǔn)的命名訪問(wèn)控制列表

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

  • tarena-R2(config)#ip access-list standard denypc2
  • tarena-R2(config-std-nacl)#deny host 192.168.0.20
  • tarena-R2(config-std-nacl)#permit any
  • tarena-R2(config-std-nacl)#exit
  • tarena-R2(config)#interface f0/1
  • tarena-R2(config-if)#ip access-group denypc2 out
  • 步驟三:分別在PC1和PC2上做連通性測(cè)試

    PC1測(cè)試如下所示:

  • PC>ipconfig
  • FastEthernet0 Connection:(default port)
  • Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
  • IP Address......................: 192.168.0.10
  • Subnet Mask.....................: 255.255.255.0
  • Default Gateway.................: 192.168.0.1
  • PC>ping 192.168.2.100
  • Pinging 192.168.2.100 with 32 bytes of data:
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Ping statistics for 192.168.2.100:
  • Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  • Approximate round trip times in milli-seconds:
  • Minimum = 0ms, Maximum = 0ms, Average = 0ms
  • PC>
  • PC2測(cè)試如下所示:

  • PC>ipconfig
  • FastEthernet0 Connection:(default port)
  • Link-local IPv6 Address.........: FE80::2D0:BAFF:FE98:9E29
  • IP Address......................: 192.168.0.20
  • Subnet Mask.....................: 255.255.255.0
  • Default Gateway.................: 192.168.0.1
  • PC>ping 192.168.2.100
  • Pinging 192.168.2.100 with 32 bytes of data:
  • Reply from 192.168.1.2: Destination host unreachable.
  • Reply from 192.168.1.2: Destination host unreachable.
  • Reply from 192.168.1.2: Destination host unreachable.
  • Reply from 192.168.1.2: Destination host unreachable.
  • Ping statistics for 192.168.2.100:
  • Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
  • PC>
  • 輸出結(jié)果表明,PC1的訪問(wèn)是正常的,而PC2到Web Server的訪問(wèn)被R2(IP地址為192.168.1.2)拒絕。

    步驟四:在R2上查看相關(guān)的ACL信息

  • tarena-R2#show ip access-lists
  • Standard IP access list denypc2
  • 10 deny host 192.168.0.20 (4 match(es))
  • 20 permit any (4 match(es))
  • 輸出結(jié)果也表明,來(lái)自于PC2的數(shù)據(jù)包被攔截。

    4 配置擴(kuò)展命名ACL

    4.1 問(wèn)題

    使用基本編號(hào)的ACL沒(méi)有實(shí)際意義,只有通過(guò)閱讀具體的條目才能得知該ACL的作用。而且ACL的編號(hào)有限制,如傳統(tǒng)的標(biāo)準(zhǔn)ACL用1~99表示,擴(kuò)展ACL用100~199表示。

    1)配置擴(kuò)展命名ACL實(shí)現(xiàn)拒絕PC2(IP地址為192.168.0.20)訪問(wèn)Web Server Web服務(wù),但可訪問(wèn)其他服務(wù)。

    4.2 方案

    命名訪問(wèn)控制列表可以為ACL起一個(gè)有意義的名字,通過(guò)名稱(chēng)就可以得知該ACL要實(shí)現(xiàn)什么功能。同時(shí),因?yàn)槭褂玫氖敲Q(chēng)而不是數(shù)字,也就沒(méi)有了ACL數(shù)量上的限制。

    網(wǎng)絡(luò)拓?fù)淙鐖D-8所示:

    圖-8

    ?

    4.3 步驟

    實(shí)現(xiàn)此案例需要按照如下步驟進(jìn)行。

    步驟一:將3配置標(biāo)準(zhǔn)命名ACL中的標(biāo)準(zhǔn)命名訪問(wèn)控制列表移除,其他配置保留

  • tarena-R2(config)#interface f0/1
  • tarena-R2(config-if)#no ip access-group denypc2 out
  • tarena-R2(config-if)#exit
  • tarena-R2(config)# no ip access-list standard denypc2
  • 步驟二:在R2上配置擴(kuò)展命名訪問(wèn)控制列表

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

  • tarena-R2(config)#ip access-list extended denypc2
  • tarena-R2(config-ext-nacl)#deny tcp host 192.168.0.20 host 192.168.2.100 eq www
  • tarena-R2(config-ext-nacl)#permit ip any any
  • tarena-R2(config)#interface fastEthernet 0/1
  • tarena-R2(config-if)#ip access-group denypc2 out
  • 步驟三:在R2上查看相關(guān)的ACL信息

  • tarena-R2#show access-lists
  • Extended IP access list denypc2
  • 10 deny tcp host 192.168.0.20 host 192.168.2.100 eq www
  • 20 permit ip any any
  • 步驟四:在PC1上驗(yàn)證

  • PC>ipconfig
  • FastEthernet0 Connection:(default port)
  • Link-local IPv6 Address.........: FE80::2E0:F7FF:FED6:54CC
  • IP Address......................: 192.168.0.10
  • Subnet Mask.....................: 255.255.255.0
  • Default Gateway.................: 192.168.0.1
  • PC>ping 192.168.2.100
  • Pinging 192.168.2.100 with 32 bytes of data:
  • Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Ping statistics for 192.168.2.100:
  • Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  • Approximate round trip times in milli-seconds:
  • Minimum = 0ms, Maximum = 1ms, Average = 0ms
  • PC>
  • HTTP協(xié)議的驗(yàn)證如圖-9所示:

    圖-9

    ?

    從輸入結(jié)果可以驗(yàn)證,PC1到Web Server的訪問(wèn)沒(méi)有受到任何影響。

    步驟五:在PC2上進(jìn)行驗(yàn)證

  • PC>ipconfig
  • FastEthernet0 Connection:(default port)
  • Link-local IPv6 Address.........: FE80::2D0:BAFF:FE98:9E29
  • IP Address......................: 192.168.0.20
  • Subnet Mask.....................: 255.255.255.0
  • Default Gateway.................: 192.168.0.1
  • PC>ping 192.168.2.100
  • Pinging 192.168.2.100 with 32 bytes of data:
  • Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=1ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=2ms TTL=126
  • Reply from 192.168.2.100: bytes=32 time=0ms TTL=126
  • Ping statistics for 192.168.2.100:
  • Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  • Approximate round trip times in milli-seconds:
  • Minimum = 0ms, Maximum = 2ms, Average = 1ms
  • PC>
  • HTTP協(xié)議的驗(yàn)證,如圖-10所示:

    圖-10

    ?

    因?yàn)橹幌拗屏说絎eb Server的HTTP訪問(wèn),所以WEB服務(wù)已經(jīng)無(wú)法訪問(wèn),但是仍然可以ping通。

    轉(zhuǎn)載于:https://www.cnblogs.com/fyy-hhzzj/p/8306048.html

    總結(jié)

    以上是生活随笔為你收集整理的HSRPSTPACL的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

    如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。