一、實驗拓撲
二、配置生成樹協議STP
- 查看三臺交換機上的生成樹建立情況
SW1:
SW1#show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 0001.C7B1.9138
Cost 19
Port 1(FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 000A.4195.78C9
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Root FWD 19 128.1 P2p /Fa0/1端口爲根端口
Fa0/2 Desg FWD 19 128.2 P2p /Fa0/2端口爲指定端口
SW2:
SW2#show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 0001.C7B1.9138
This bridge is the root /該交換機爲根橋,根橋的所有端口都爲指定端口
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 0001.C7B1.9138
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2 Desg FWD 19 128.2 P2p /Fa0/1端口爲指定端口
Fa0/1 Desg FWD 19 128.1 P2p /Fa0/2端口爲指定端口
SW3:
SW3#show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 0001.C7B1.9138
Cost 19
Port 1(FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 00E0.F7BC.D5C9
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2 Altn BLK 19 128.2 P2p /Fa0/2端口爲阻塞端口
Fa0/1 Root FWD 19 128.1 P2p /Fa0/1端口爲根端口
- 交換機自動建立的生成樹中SW2爲根橋,實際中我們更希望性能更高的三層交換機SW1來擔任根橋的重任,所以要手動將SW1交換機指定爲根橋,可以通過修改橋ID來實現。橋ID爲4096的整數倍,交換機會提示我們都有哪些合法的值。
SW1:
SW1(config)#spanning-tree vlan 1 priority 123 /修改交換機的優先級
% Bridge Priority must be in increments of 4096.
% Allowed values are:
0 4096 8192 12288 16384 20480 24576 28672
32768 36864 40960 45056 49152 53248 57344 61440
SW1(config)#
當指定的優先級數值不符合要求時,交換機便會給出合法的值
SW1(config)#spanning-tree vlan 1 priority 4096 /將SW1優先級設置爲4096
現在可以看到SW3的兩個端口都變爲橘×××,此時生成樹協議正在重新計算生成樹,重新制定端口的狀態
生成樹重新建立完成,SW1成爲根橋
SW1#show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 4097
Address 000A.4195.78C9
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 4097 (priority 4096 sys-id-ext 1)
Address 000A.4195.78C9
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg FWD 19 128.1 P2p
Fa0/2 Desg FWD 19 128.2 P2p
另一種方法設置根橋:
SW1(config)#spanning-tree vlan 1 root primary
此命令是將該根橋的優先級從現有網絡環境中的最小優先級上再減掉4096,直接將該交換機設爲根橋。