網路拓撲如下圖所示,PC0和PC1同屬VLAN10,S0和S1之間雙線路連線,透過實施快速PVST+實現網路的正常工作,同時保證網路的可用性。
S0(config)#vlan 10
S0(config)#spanning-tree mode rapid-pvst
S0(config)#spanning-tree vlan 10 rootprimary
S0(config)#interface f0/3
S0(config-if)#switchport access vlan 10
S0(config-if)#spanning-tree portfast
S0(config)#interface range f0/1-f0/2
S0(config-if-range)#switchport trunkencapsulation dot1q
S0(config-if-range)#switchport mode trunk
S0(config-if-range)#switchport trunkallowed vlan 10
S1(config)#vlan 10
S1(config-vlan)#exit
S1(config)#spanning-tree mode rapid-pvst
S1(config)#spanning-tree vlan 10 rootsecondary
S1(config)#interface f0/3
S1(config-if)#switchport access vlan 10
S1(config-if)#spanning-tree portfast
S1(config)#interface range f0/1-f0/2
S1(config-if-range)#switchport trunkencapsulation dot1q
S1(config-if-range)#switchport mode trunk
S1(config-if-range)#switchport trunkallowed vlan 10
透過命令show spanning-tree summary可以查出當前生成樹協議工作在快速PVST+模式,Switch is in rapid-pvst mode。
分別在S0和S1上輸入showspanning-tree active檢視VLAN10生成樹的情況,屬於VLAN10的介面都參與到了生成樹的計算,可以發現S1的f0/2口被阻塞(BLK=block),作為備用介面,其他介面均是轉發(FWD=forward)介面。