拓撲如上圖,Sw1爲根交換機,Sw2爲備份根交換機,Sw3爲接入層交換機。
配置:SW1spanning-tree vlan 1 priority 8192 SW2:spanning-tree vlan 1 priority 16384。
經過在SW3上查看。
SW3#show span brief
VLAN1
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address cc00.0dd4.0000
Cost 19
Port 4 (FastEthernet0/3)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768
Address cc02.0dd4.0000
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
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/2 128.3 128 19 BLK 19 16384 cc01.0dd4.0000 128.3
FastEthernet0/3 128.4 128 19 FWD 0 8192 cc00.0dd4.0000 128.4
FastEthernet0/4 128.5 128 19 FWD 19 32768 cc02.0dd4.0000 128.5
1、Portfast特性。
開啓portfast特性的端口又叫快速端口,配置在接口端口上,鏈接主機或路由器的端口上啓用,不能與鏈接交換機的端口啓用。不然或出現環路。默認的狀況下接口從接入到Forwarding狀態須要通過30s的時間,通過listening、learning狀態。驗證:
將SW3的Fa0/4關閉,開啓degbu spanning-tree event。
SW3(config)#inter f0/4
SW3(config-if)#no shu
SW3(config-if)#
*Mar 1 00:03:00.591: STP: VLAN1 Fa0/4 -> listening
*Mar 1 00:03:03.355: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to up
*Mar 1 00:03:15.611: STP: VLAN1 Fa0/4 -> learning
*Mar 1 00:03:30.631: STP: VLAN1 sent Topology Change Notice on Fa0/3
*Mar 1 00:03:30.635: STP: VLAN1 Fa0/4 -> forwarding
下面開啓Portfast特性。
在SW3的Fa0/4接口下:
SW3(config-if)#spanning-tree portfast
%Warning: portfast should only be enabled on ports connected to a single host.
Connecting hubs, concentrators, switches, bridges, etc.to this interface
when portfast is enabled, can cause temporary spanning tree loops.
Use with CAUTION
%Portfast has been configured on FastEthernet0/4 but will only
have effect when the interface is in a non-trunking mode.
SW3(config)#inter f0/4
SW3(config-if)#no shu
SW3(config-if)#
*Mar 1 00:05:36.435: STP: VLAN1 Fa0/4 ->jump to forwarding from blocking
*Mar 1 00:05:39.171: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to up
直接進入Forwarding狀態。節省30s。
2、uplinkfast。
uplinkfast也叫快速上行端口,在上圖所示的拓撲中,接入交換機有兩條上行鏈路若是主鏈路down,備份鏈路須要通過30s的時間纔可以恢復到Forwarding狀態。
驗證:
在SW3上將Fa0/3端口。
SW3(config)#int f0/3
SW3(config-if)#shu
SW3(config-if)#
*Mar 1 00:06:47.763: STP: VLAN1 Fa0/3 -> blocking
*Mar 1 00:06:47.763: STP: VLAN1 new root port Fa0/2, cost 38
*Mar 1 00:06:47.835: STP: VLAN1 Fa0/2 -> listening
*Mar 1 00:06:49.687: %LINK-5-CHANGED: Interface FastEthernet0/3, changed state to administratively down
*Mar 1 00:06:49.687: STP: VLAN1 sent Topology Change Notice on Fa0/2
*Mar 1 00:06:50.687: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
*Mar 1 00:07:02.855: STP: VLAN1 Fa0/2 -> learning
*Mar 1 00:07:17.875: STP: VLAN1 sent Topology Change Notice on Fa0/2
*Mar 1 00:07:17.879: STP: VLAN1 Fa0/2 -> forwarding
如今啓用uplinkfast,SW3上全局啓用。uplinkfast通常在接×××換機上啓用。核心和匯聚交換機最好不要啓用。
SW3(config)#spanning-tree uplinkfast
SW3(config-if)#shut
SW3(config-if)#
*Mar 1 02:53:35.555: STP: VLAN1 Fa0/3 -> blocking
*Mar 1 02:53:35.555: STP: VLAN1 new root port Fa0/2, cost 3038
*Mar 1 02:53:35.555: %SPANTREE_FAST-7-PORT_FWD_UPLINK: VLAN1 FastEthernet0/2 moved to Forwarding (UplinkFast).
備份鏈路接口Fa0/2直接進入Forwarding狀態。節省30s。
注:啓用uplinkfast之後,生成樹的優先級將變成49152,接口的生成樹cost增長3000。
SW3#show span br
VLAN1
Spanning tree enabled protocol ieee uplinkfast enabled
Root ID Priority 8192
Address cc00.0dd4.0000
Cost 3038
Port 3 (FastEthernet0/2)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 49152
Address cc02.0dd4.0000
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
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/2 128.3 128 3019 FWD 19 16384 cc01.0dd4.0000 128.3
FastEthernet0/3 128.4 128 3019 BLK 0 8192 cc00.0dd4.0000 128.4
FastEthernet0/4 128.5 128 3019 FWD 3038 49152 cc02.0dd4.0000 128.5
3、Backbonefast(快速骨幹)
在上圖SW1和SW2的直連鏈路若是出現故障,那麼SW2將沒法識別根交換機的位置,SW2就會發送次級BPDU標識本身是根,SW3的阻塞端口收到次級BPDU之後,將會進入老化時間,而後通過listening、learning狀態才能到達Forwarding狀態,這一過程須要50s的時間。
驗證:
將SW2的Fa0/1關閉。
SW2(config)#inter fa0/1
SW2(config-if)#shutdown
SW3#
*Mar 1 01:02:30.967: STP: VLAN1 heard root 16384-cc01.0dd4.0000 on Fa0/2
*Mar 1 01:02:30.967: current Root has 8192-cc00.0dd4.0000
*Mar 1 01:02:32.931: STP: VLAN1 heard root 16384-cc01.0dd4.0000 on Fa0/2
*Mar 1 01:02:32.931: current Root has 8192-cc00.0dd4.0000
*Mar 1 01:02:34.919: STP: VLAN1 heard root 16384-cc01.0dd4.0000 on Fa0/2
*Mar 1 01:02:34.919: current Root has 8192-cc00.0dd4.0000
*Mar 1 01:02:36.907: STP: VLAN1 heard root 16384-cc01.0dd4.0000 on Fa0/2
*Mar 1 01:02:36.907: current Root has 8192-cc00.0dd4.0000
*Mar 1 01:02:38.927: STP: VLAN1 heard root 16384-cc01.0dd4.0000 on Fa0/2
*Mar 1 01:02:38.927: current Root has 8192-cc00.0dd4.0000
*Mar 1 01:02:40.931: STP: VLAN1 heard root 16384-cc01.0dd4.0000 on Fa0/2
*Mar 1 01:02:40.931: current Root has 8192-cc00.0dd4.0000
*Mar 1 01:02:42.923: STP: VLAN1 heard root 16384-cc01.0dd4.0000 on Fa0/2
*Mar 1 01:02:42.923: current Root has 8192-cc00.0dd4.0000
*Mar 1 01:02:44.931: STP: VLAN1 heard root 16384-cc01.0dd4.0000 on Fa0/2
*Mar 1 01:02:44.931: current Root has 8192-cc00.0dd4.0000
*Mar 1 01:02:46.935: STP: VLAN1 heard root 16384-cc01.0dd4.0000 on Fa0/2
*Mar 1 01:02:46.935: current Root has 8192-cc00.0dd4.0000
*Mar 1 01:02:48.927: STP: VLAN1 heard root 16384-cc01.0dd4.0000 on Fa0/2
*Mar 1 01:02:48.927: current Root has 8192-cc00.0dd4.0000
*Mar 1 01:02:48.987: STP: VLAN1 Fa0/2 -> listening
*Mar 1 01:02:50.023: STP: VLAN1 Topology Change rcvd on Fa0/2
*Mar 1 01:02:50.027: STP: VLAN1 sent Topology Change Notice on Fa0/3
*Mar 1 01:03:04.007: STP: VLAN1 Fa0/2 -> learning
*Mar 1 01:03:19.031: STP: VLAN1 sent Topology Change Notice on Fa0/3
*Mar 1 01:03:19.031: STP: VLAN1 Fa0/2 -> forwarding
通過50s的時間。
配置backbonefast,在全部的交換機上全局啓用。spanning-tree backbonefast
配置backbonefast特性之後,當SW3收到次級BPDU時,他會向根交換機SW1發送RLQ BPDU(根鏈路查詢BPDU)查詢根交換機是否仍然處於激活狀態,SW1收到RLQ BPDU之後會發送一個RLQ 確認。SW3收到RLQ的確認之後會將收到次級BPDU的阻塞端口跳過老化時間,直接進入listening狀態,節省20s的時間。
SW2(config)#inter fa0/1
SW2(config-if)#shutdown
SW3#
*Mar 1 01:05:11.735: STP: VLAN1 heard root 16384-cc01.0dd4.0000 on Fa0/2 *Mar 1 01:05:11.735: current Root has 8192-cc00.0dd4.0000 *Mar 1 01:05:11.815: STP: VLAN1 Fa0/2 -> listening *Mar 1 01:05:11.975: STP: VLAN1 Topology Change rcvd on Fa0/2 *Mar 1 01:05:11.975: STP: VLAN1 sent Topology Change Notice on Fa0/3 *Mar 1 01:05:26.835: STP: VLAN1 Fa0/2 -> learning *Mar 1 01:05:41.859: STP: VLAN1 sent Topology Change Notice on Fa0/3 *Mar 1 01:05:41.859: STP: VLAN1 Fa0/2 -> forwarding