1.实验目的
- 理解生成树STP的选举过程
- 掌握生成树STP接口角色切换的操作
2.拓扑与需求
拓扑:
需求:
- 默认情况下阻塞的是SW3的e0/1接口,保持SW1根桥角色不变的情况下,将阻塞接口切换为SW2的e0/1接口。
- 保持SW1为根桥的情况下,将SW2的E0/0接口阻塞
3.配置与实现
- 默认情况下阻塞的是SW3的e0/1接口,保持SW1根桥角色不变的情况下,将阻塞接口切换为SW2的e0/1接口。
分析:根据生成树选举原则,SW3的E0/1被阻塞是由于竞争指定接口失败,而选举指定接口的规则为:在每段链路上选举一个接口为指定接口
- 离根近的接口
- 发送BPDU者的BID(桥ID)较小
- 发送BPDU者的PID(端口ID)较小
在本实验中,SW2的e0/1和SW3的e0/1距离根桥(SW1)的距离相等,而SW2本身的BID较小故SW2的e0/1成为指定接口,而SW3的E0/1接口被阻塞
操作思路:通过操作接口的cost使得SW3的E0/1比SW2的0/1接口到达根桥的距离更近
SW3配置:
Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname R3
R3(config)#^Z
R3#show
*Apr 20 13:10:48.327: %SYS-5-CONFIG_I: Configured from console by console
R3#show spa
R3#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.1400
Cost 100
Port 3 (Ethernet0/2)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address aabb.cc00.5400
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0 Desg FWD 100 128.1 P2p
Et0/1 Altn BLK 100 128.2 P2p
Et0/2 Root FWD 100 128.3 P2p
Et0/3 Desg FWD 100 128.4 P2p
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int e0/2
R3(config-if)#spa
R3(config-if)#spanning-tree cost 1
R3(config-if)#
R3#
*Apr 20 13:11:48.506: %SYS-5-CONFIG_I: Configured from console by console
R3#show spa
R3#show spanning-tree vlan
% Incomplete command.
R3#
*Apr 20 13:11:54.826: %PNP-6-PNP_DISCOVERY_STOPPED: PnP Discovery stopped (Config Wizard)
R3#show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.1400
Cost 1
Port 3 (Ethernet0/2)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address aabb.cc00.5400
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0 Desg FWD 100 128.1 P2p
Et0/1 Desg LRN 100 128.2 P2p
Et0/2 Root FWD 1 128.3 P2p
Et0/3 Desg FWD 100 128.4 P2p
R3配置如图所示
可以看到R2的E0/1端口已经阻塞
SW2#show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.1400
Cost 100
Port 1 (Ethernet0/0)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address aabb.cc00.2400
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0 Root FWD 100 128.1 P2p
Et0/1 Altn BLK 100 128.2 P2p
Et0/2 Desg FWD 100 128.3 P2p
Et0/3 Desg FWD 100 128.4 P2p
2.保持SW1为根桥的情况下,将SW2的E0/0接口阻塞
操作思路,调整SW2 E0/1的cost,使得两条链路(SW2 E0/1--SW3 0/2---SW1)的cost和小于100 即可
SW2配置:
SW2#
*Apr 20 13:18:47.244: %PNP-6-PNP_DISCOVERY_STOPPED: PnP Discovery stopped (Config Wizard)
SW2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
SW2(config)#int e0/1
SW2(config-if)#span
SW2(config-if)#spanning-tree cost 98
SW2(config-if)#
SW2#sh
*Apr 20 13:19:45.073: %SYS-5-CONFIG_I: Configured from console by console
SW2#show spa
SW2#show spanning-tree clan 1
^
% Invalid input detected at '^' marker.
SW2#show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.1400
Cost 99
Port 2 (Ethernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address aabb.cc00.2400
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Et0/0 Altn BLK 100 128.1 P2p
Et0/1 Root LRN 98 128.2 P2p
Et0/2 Desg FWD 100 128.3 P2p
Et0/3 Desg FWD 100 128.4 P2p
如图所示可以看到R2的E0/0端口已经被阻塞
实验结束