一、实验拓扑
二、配置生成树协议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端口为根端口
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,直接将该交换机设为根桥。