实验拓扑图:
实验过程
1.启动sw1和sw2,查看sw1的生成树状态
sw1#show spanning-tree brief
VLAN1 Spanning tree enabled protocol ieee Root ID Priority 32768 Address cc02.070c.0000 This bridge is the root //sw1是根桥 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768 //BID由优先级和MAC地址组成 Address cc02.070c.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/1 128.2 128 19 FWD 0 32768 cc02.070c.0000 128.2 FastEthernet0/2 128.3 128 19 FWD 0 32768 cc02.070c.0000 128.3 |
说明:通过以上可以看到sw1是根桥,它的两个端口都是指定端口,并且处于转发状态。
2.查看sw2的生成树状态
sw2#show spanning-tree brief
VLAN1 Spanning tree enabled protocol ieee Root ID Priority 32768 Address cc02.070c.0000 Cost 19 Port 2 (FastEthernet0/1) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768 //桥优先级默认是32768,可以修改 Address cc03.070c.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/1 128.2 128 19 FWD 0 32768 cc02.070c.0000 128.2 FastEthernet0/2 128.3 128 19 BLK 0 32768 cc02.070c.0000 128.3 |
说明:sw2是非根桥,它有一个端口处于阻塞状态,不进行数据包的转发。
3.分析
1.选举根桥 在优先级(默认32768)相同的情况下选择MAC地址小的为RB,所以sw1成为RB。 2.选举根端口 比较顺序:cost最小+BID最小+端口优先级+本地最小端口号 sw2到sw1的cost都是19,BID也相同,端口优先级都是128,由于f0/1比f0/2小,所有f0/1成为RP。 3.选举指定端口 sw1的f0/1和f0/2是DP。 4.选举非指派端口 sw2的f0/2是NDP |
4.把sw2修改成 root primary
sw2(config)#spanning-tree vlan 1 root primary //指定sw2为vlan 1的根桥 VLAN 1 bridge priority set to 8192 VLAN 1 bridge max aging time unchanged at 20 VLAN 1 bridge hello time unchanged at 2 VLAN 1 bridge forward delay unchanged at 15 |
5.再次查看sw1生成树状态
sw1#show spanning-tree brief
VLAN1 Spanning tree enabled protocol ieee Root ID Priority 8192 Address cc03.070c.0000 Cost 19 Port 2 (FastEthernet0/1) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768 Address cc02.070c.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/1 128.2 128 19 FWD 0 8192 cc03.070c.0000 128.2 FastEthernet0/2 128.3 128 19 BLK 0 8192 cc03.070c.0000 128.3 |
6.查看sw2生成树状态
sw2#show spanning-tree brief
VLAN1 Spanning tree enabled protocol ieee Root ID Priority 8192 Address cc03.070c.0000 This bridge is the root //sw2把自己的优先级修改成8192,优先级比sw1小,优先变成RB Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 8192 Address cc03.070c.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/1 128.2 128 19 FWD 0 8192 cc03.070c.0000 128.2 FastEthernet0/2 128.3 128 19 FWD 0 8192 cc03.070c.0000 128.3 |
7.再次修改sw1的优先级为0
sw1(config)#spanning-tree vlan 1 priority 0 |
8.查看sw1的生成树状态
sw1#show spanning-tree brief
VLAN1 Spanning tree enabled protocol ieee Root ID Priority 0 Address cc02.070c.0000 This bridge is the root //由于sw1的优先级比sw2的小,所以sw1又成为RB Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 0 Address cc02.070c.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/1 128.2 128 19 FWD 0 0 cc02.070c.0000 128.2 FastEthernet0/2 128.3 128 19 FWD 0 0 cc02.070c.0000 128.3 |
9.查看sw2的生成树状态
sw2#show spanning-tree brief
VLAN1 Spanning tree enabled protocol ieee Root ID Priority 0 Address cc02.070c.0000 Cost 19 Port 2 (FastEthernet0/1) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 8192 Address cc03.070c.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/1 128.2 128 19 FWD 0 0 cc02.070c.0000 128.2 FastEthernet0/2 128.3 128 19 BLK 0 0 cc02.070c.0000 128.3 |
10.再次把sw2修改成 root primary
sw2(config)#spanning-tree vlan 1 root primary % Unable to make this switch the root of VLAN1 spanning tree because root cc02.070c.0000 has priority 0 //由于sw1的优先级已经变成0了,sw2已经无法把自己的优先级变得更小去抢根桥。 |
转载于:https://blog.51cto.com/mxn19871215/482759