拓扑如上图,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
一、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。
二、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
三、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