您好,登錄后才能下訂單哦!
STP(Spanning Tree Protocol),是生成樹協議的縮寫。在實際的網絡環境中,通過物理鏈路備份可以實現鏈路的冗余,從而提高網絡的可靠性。但是,交換網絡會形成一個環路,根據交換機的轉發原理(交換機向除接收端口之外的所有端口轉發廣播幀),會形成廣播風暴,導致網絡癱瘓。而STP協議正是用來解決二層環路的,STP協議通過一些特定的算法,在邏輯上阻塞一些端口,把一個環形的結構改變成一個邏輯上的樹形結構,當正常通信的線路出現故障時,被阻塞的端口會被重新激活,使數據能夠從這條線路上正常傳輸。此協議在Cisco交換機上默認為開啟。
HSRP(Hot Standby Router Protocol),熱備份路由選擇協議,是思科的一種私有協議。該協議中有多臺路由器,對應一個HSPR組,該組只有一臺路由器承擔轉發用戶流量的職責,稱為活躍路由器(路由器優先級最高,通常手工指定),另一臺為備份路由器。當活躍路由器失效時,備份路由器將承擔所有流量的轉發,成為新的活躍路由器,這就是熱備份的原理。
示例:公司內部網絡拓樸圖如下:
架構說明:
1)IP規劃:
vlan 10:172.16.10.0/24 網關:172.16.10.253
vlan 20:172.16.20.0/24 網關:172.16.20.253
vlan 100:172.16.100.0/24 網關:172.16.100.253 (設備管理)
2)通過STP和HSRP實現VLAN間的負載均衡,奇數開始的VLAN以SW1為活躍路由器,以SW2為備份路由器。偶數開始的VLAN以SW2為活躍路由器,以SW1為備份路由器。即:
SW1作為vlan10的活躍路由器,vlan20的備份路由器
SW2作為vlan 20的活躍路由器,vlan10的備份路由器
配置如下:
1)配置基本信息:
ROUTER的配置信息:
ROUTER(config)#hostname ROUTER
ROUTER(config)#int f1/0
ROUTER(config-if)#ip add 172.16.1.5 255.255.255.252
ROUTER(config-if)#no sh
ROUTER(config-if)#int f0/0
ROUTER(config-if)#ip add 172.16.1.2 255.255.255.252
ROUTER(config-if)#no sh
ROUTER(config)#ip route 172.16.10.0 255.255.255.0 172.16.1.1
ROUTER(config)#ip route 172.16.20.0 255.255.255.0 172.16.1.1
ROUTER(config)#ip route 172.16.100.0 255.255.255.0 172.16.1.1
ROUTER(config)#ip route 172.16.10.0 255.255.255.0 172.16.1.6
ROUTER(config)#ip route 172.16.20.0 255.255.255.0 172.16.1.6
ROUTER(config)#ip route 172.16.100.0 255.255.255.0 172.16.1.6
ROUTER#wr
SW1的配置信息:
SW1(config)#hostname SW1
SW1(config)#ip routing
SW1(config)#int f1/8
SW1(config-if)#no switchport
SW1(config-if)#ip add 172.16.1.1 255.255.255.252
SW1(config-if)#no sh
SW1(config)#int range f1/5 - 6
SW1(config-if-range)#channel-group 1 mode on
SW1(config)#int range port-channel 1 , f1/0 - 1
SW1(config-if-range)#sw trunk encapsulation dot1q
SW1(config-if-range)#sw mo tr
SW1(config)#vlan 10
SW1(config-vlan)#vlan 20
SW1(config-vlan)#vlan 100
SW1(config)#vtp domain cisco
SW1(config)#vtp password cisco
SW1(config)#vtp mode server
SW1(config)#vtp pruning
SW1(config)#int vlan 100
SW1(config-if)#ip add 172.16.100.253 255.255.255.0
SW1(config-if)#no sh
SW1(config)#ip route 0.0.0.0 0.0.0.0 172.16.1.2
SW1#wr
SW2的配置信息:
SW2(config)#hostname SW2
SW2(config)#ip routing
SW2(config)#int f1/8
SW2(config-if)#no switchport
SW2(config-if)#ip add 172.16.1.6 255.255.255.252
SW2(config-if)#no sh
SW2(config)#int range f1/5 - 6
SW2(config-if-range)#channel-group 1 mode on
SW2(config)#int range port-channel 1 , f1/1 - 2
SW2(config-if-range)#sw trunk encapsulation dot1q
SW2(config-if-range)#sw mo tr
SW2(config)#vtp domain cisco
SW2(config)#vtp password cisco
SW2(config)#vtp mode client
SW2(config)#int vlan 100
SW2(config-if)#ip add 172.16.100.2 255.255.255.0
SW2(config-if)#no sh
SW2#wr
SW2#sh vlan-swi
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa1/0, Fa1/3, Fa1/4, Fa1/7
Fa1/9, Fa1/10, Fa1/11, Fa1/12
Fa1/13, Fa1/14, Fa1/15
10 VLAN0010 active
20 VLAN0020 active
100 VLAN0100 active
...
SW2(config)#ip route 0.0.0.0 0.0.0.0 172.16.1.5
SW2#wr
s3的配置信息:
s3(config)#int range f1/0 - 1
s3(config-if-range)#sw mo tr
s3(config)#vtp domain cisco
s3(config)#vtp password cisco
s3(config)#vtp mode client
s3(config)#int f1/8
s3(config-if)#sw mo ac
s3(config-if)#sw ac vlan 10
s3(config)#int vlan 100
s3(config-if)#ip add 172.16.100.3 255.255.255.0
s3(config-if)#no sh
s3(config)#ip default-gateway 172.16.100.253
s3#wr
s3#sh vlan-swi
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa1/2, Fa1/3, Fa1/4, Fa1/5
Fa1/6, Fa1/7, Fa1/9, Fa1/10
Fa1/11, Fa1/12, Fa1/13, Fa1/14
Fa1/15
10 VLAN0010 active Fa1/8
20 VLAN0020 active
s4的配置信息:
s4(config)#int range f1/1 - 2
s4(config-if-range)#sw mo tr
s4(config)#vtp domain cisco
s4(config)#vtp password cisco
s4(config)#vtp mode client
s4(config)#int f1/11
s4(config-if)#sw mo ac
s4(config-if)#sw ac vl 20
s4(config)#int vlan 100
s4(config-if)#ip add 172.16.100.4 255.255.255.0
s4(config-if)#no sh
s4#wr
s4#sh vlan-swi
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa1/0, Fa1/3, Fa1/4, Fa1/5
Fa1/6, Fa1/7, Fa1/8, Fa1/9
Fa1/10, Fa1/12, Fa1/13, Fa1/14
Fa1/15
10 VLAN0010 active
20 VLAN0020 active Fa1/11
...
s4#sh vtp status
VTP Version : 2
Configuration Revision : 4
Maximum VLANs supported locally : 36
Number of existing VLANs : 8
VTP Operating Mode : Client
VTP Domain Name : cisco
VTP Pruning Mode : Enabled
VTP V2 Mode : Disabled
VTP Traps Generation : Disabled
MD5 digest : 0x03 0xC2 0xA3 0x35 0xCA 0xAA 0x8D 0x32
Configuration last modified by 172.16.1.1 at 3-1-02 01:11:32
2)分別在SW1、SW2上配置DHCP服務(完全一致):
SW1(config)#ip dhcp pool vlan10
SW1(dhcp-config)#network 172.16.10.0 255.255.255.0
SW1(dhcp-config)#dns-server 202.96.134.133 8.8.8.8
SW1(dhcp-config)#default-router 172.16.10.253
SW1(config)#ip dhcp excluded-address 172.16.10.250 172.16.10.254
SW1(config)#ip dhcp pool vlan20
SW1(dhcp-config)#network 172.16.20.0 255.255.255.0
SW1(dhcp-config)#dns-server 202.96.134.133 8.8.8.8
SW1(dhcp-config)#default-router 172.16.20.253
SW1(config)#ip dhcp excluded-address 172.16.20.250 172.16.20.254
SW2#wr
SW1#sh run | sec dhcp
no ip dhcp use vrf connected
ip dhcp excluded-address 172.16.10.250 172.16.10.254
ip dhcp excluded-address 172.16.20.250 172.16.20.254
ip dhcp pool vlan10
network 172.16.10.0 255.255.255.0
dns-server 202.96.134.133 8.8.8.8
default-router 172.16.10.253
ip dhcp pool vlan20
network 172.16.20.0 255.255.255.0
dns-server 202.96.134.133 8.8.8.8
default-router 172.16.10.253
3)配置HSRP:
SW1配置:
SW1(config)#int vlan 10
SW1(config-if)#ip add 172.16.10.250 255.255.255.0
SW1(config-if)#no sh
SW1(config-if)#standby 10 ip 172.16.10.253 #配置虛擬IP
SW1(config-if)#standby 10 priority 150 #配置優先級
SW1(config-if)#standby 10 preempt #配置占先權
SW1(config-if)#standby 10 track f1/8 100 #配置端口跟蹤
SW1(config-if)#standby 10 track port-channel 1 100
SW1(config)#int vlan 20
SW1(config-if)#ip add 172.16.20.250 255.255.255.0
SW1(config-if)#no sh
SW1(config-if)#standby 20 ip 172.16.20.253 #作為vlan20的備份路由器,優先級
SW1(config-if)#standby 20 preempt 默認為100,并且不需要配置端口跟蹤
SW1(config-if)#int vlan 100
SW1(config-if)#ip add 172.16.100.253 255.255.255.0
SW1(config-if)#no sh
SW1#wr
SW2的配置:
SW2(config)#int vlan 10
SW2(config-if)#ip add 172.16.10.251 255.255.255.0
SW2(config-if)#no sh
SW2(config-if)#standby 10 ip 172.16.10.253
SW2(config-if)#standby 10 preempt
SW2(config)#int vlan 20
SW2(config-if)#ip add 172.16.20.251 255.255.255.0
SW2(config-if)#no sh
SW2(config-if)#standby 20 ip 172.16.20.253
SW2(config-if)#standby 20 priority 150
SW2(config-if)#standby 20 preempt
SW2(config-if)#standby 20 track f1/8 100
SW2(config-if)#standby 20 track port-channel 1 100
SW2#wr
SW1#sh standby b #在SW1上驗證
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Vl10 10 150 P Active local 172.16.10.251 172.16.10.253
Vl20 20 100 P Standby 172.16.20.251 local 172.16.20.253
Vl100 10 100 Init unknown unknown 172.16.10.254
SW2#sh standby b #在SW2上驗證
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Vl10 10 100 P Standby 172.16.10.250 local 172.16.10.253
Vl20 20 150 P Active local 172.16.20.250 172.16.20.253
4)配置STP,實現VLAN間的負載均衡:
SW1(config)#spanning-tree vlan 10 root primary
SW1(config)#spanning-tree vlan 20 root secondary
SW1#wr
SW2(config)#spanning-tree vlan 20 root primary
SW2(config)#spanning-tree vlan 10 root secondary
SW2#wr
在SW1上查看STP信息,可見SW1是VLAN10的根網橋,是VLAN20的備份根橋。
SW1#sh spanning-tree brief
VLAN10
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c006.1e3c.0001
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 8192
Address c006.1e3c.0001
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/0 128.41 128 19 FWD 0 8192 c006.1e3c.0001 128.41
FastEthernet1/1 128.42 128 19 FWD 0 8192 c006.1e3c.0001 128.42
Port-channel1 129.65 128 12 FWD 0 8192 c006.1e3c.0001 129.65
在s3上查看,可見f1/1的端口被阻塞
s3#sh spanning-tree vlan 10
...
Port 42 (FastEthernet1/1) of VLAN10 is blocking
Port path cost 19, Port priority 128, Port Identifier 128.42.
Designated root has priority 8192, address c006.1e3c.0001
Designated bridge has priority 16384, address c007.1e3c.0001
Designated port id is 128.42, designated path cost 12
Timers: message age 3, forward delay 0, hold 0
Number of transitions to forwarding state: 0
BPDU: sent 2, received 2298
...
5)配置遠程SSH管理:
SW1(config)#ip domain-name cisco
SW1(config)#username best password best1
SW1(config)#crypto key generate rsa general-keys modulus 1024
SW1(config)#ip ssh version 2
SW1(config)#enable secret cisco
SW1(config)#access-list 1 permit 172.16.20.0 0.0.0.255
SW1(config)#line vty 0 4
SW1(config-line)#login local
SW1(config-line)#access-class 1 in
SW1(config-line)#transport input ssh
SW1#wr
在客戶端遠程登陸:
R6#ssh -l best 172.16.100.253
Password:
SW1>en
Password:
SW1#sh ip int b
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset administratively down down
FastEthernet0/1 unassigned YES unset administratively down down
FastEthernet1/0 unassigned YES unset up up
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。