目录
实验条件
网络拓朴
需求
● 理解生成树STP的选举过程
● 掌握生成树STP接口角色切换的操作
配置实现
默认情况阻塞的是SW3的E0/1接口,保持SW1根桥角色不变的情况下,将阻塞接口切换到SW2的E0/1接口
三台交换机状态如下
SW1
SW1#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.1000
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 aabb.cc00.1000
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 Desg FWD 100 128.2 P2p
Et0/2 Desg FWD 100 128.3 P2p
Et0/3 Desg FWD 100 128.4 P2p
SW1#
SW2
SW2#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.1000
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.2000
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 Desg FWD 100 128.2 P2p
Et0/2 Desg FWD 100 128.3 P2p
Et0/3 Desg FWD 100 128.4 P2p
SW2#
SW3
SW3#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.1000
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.3000
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
SW3#
根据生成树选举规则,SW3的E0/1被阻塞是由于竞争指定接口失败,而选举指定接口的规则为:
在每段链路上选举一个接口成为指定接口
1. 离根近的接口(Cost较小)
2. 发送BPDU者的 Bridge ID 较小
3. 发送BPDU者的 Port ID 较小
在本实验中,SW2的E0/1和SW3的E0/1距离根桥SW1的距离(Cost)相等,而SW2本身的 Bridge ID 较小,故SW2的E0/1成为指定接口,SW3的E0/1被阻塞
现在要在保持SW1根桥角色不变的情况下,将阻塞接口切换到SW2的E0/1接口
, 只需要调整两个口到根的cost就可以达到目的了, SW2到SW1的cost,取决于e0/0的cost值, SW3到SW1的cost取决于e0/2的cost值,
因此可以调大SW2的e0/0口的cost值, 或是调小SW3的e0/2口的cost值
这样SW2的e0/1就会变化AP口(预备端口) SW3的e0/1就会变成DP口(指定端口)
SW3(config)#do sh spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.1000
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.3000
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
SW3(config)#int e0/2
SW3(config-if)#spanning-tree cost 1
SW3(config-if)#do show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.1000
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.3000
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 LIS 100 128.2 P2p
Et0/2 Root FWD 1 128.3 P2p
Et0/3 Desg FWD 100 128.4 P2p
SW3(config-if)#
SW2
SW2#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.1000
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.2000
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
SW2#
目的达成.
保持SW1根桥角色不变的情况下,将阻塞接口切换到SW2的E0/0接口要如何操作?
在第一步的基础上,成功将阻塞接口切换到了SW2的E0/1,需求要求将阻塞接口切换到SW2的E0/0,也就意味着我们需要将根端口的角色从SW2的E0/0切换到E0/1,这样才能阻塞掉E0/0
根据生成树选举规则,根端口的规则为:
在每台非根桥上选举一个接口成为根端口
1. 离根近的接口(Cost较小)
2. 发送BPDU者的 Bridge ID 较小
3. 发送BPDU者的 Port ID 较小
SW2的E0/0到达根桥的距离(Cost)为100,而SW2的E0/1到达根桥的距离(Cost)也为100,但是需要加上SW3的E0/2的Cost=1,所以SW2的E0/1到达根桥的距离实际上是100+1=101, 如果要达到目的,可以修改SW2的e0/1口的为98,这样加起来为99,小于100,就可以达到目的.
如果还原上面的设置.则用以下的分析
SW2的E0/0到达根桥的距离(Cost)为100,而SW2的E0/1到达根桥的距离(Cost)也为100,但是需要加上SW3的E0/2的Cost=100,所以SW2的E0/1到达根桥的距离实际上是100+100=200, 如果要达到目的,可以修改SW2的e0/0口的为201,大于100,就可以达到目的.
SW2(config)#do show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.1000
Cost 201
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.2000
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 201 128.1 P2p
Et0/1 Desg FWD 101 128.2 P2p
Et0/2 Desg FWD 100 128.3 P2p
Et0/3 Desg FWD 100 128.4 P2p
SW2(config)#int e0/0
SW2(config-if)#spanning-tree cost 202
SW2(config-if)#do show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address aabb.cc00.1000
Cost 201
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.2000
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 202 128.1 P2p
Et0/1 Root LIS 101 128.2 P2p
Et0/2 Desg FWD 100 128.3 P2p
Et0/3 Desg FWD 100 128.4 P2p
SW2(config-if)#