Sw4#show int | in bia Hardware is Ethernet, address is aabb.cc00.4000 (bia aabb.cc00.4000) Hardware is Ethernet, address is aabb.cc00.4010 (bia aabb.cc00.4010) Hardware is Ethernet, address is aabb.cc00.4020 (bia aabb.cc00.4020) Hardware is Ethernet, address is aabb.cc00.4030 (bia aabb.cc00.4030)
每个非根桥上选择一个根端口
经过上面的步骤,不是根桥的交换机会根据各个接口收到的BPDU信息判断出根端口
最低根桥ID(正常情况下,收到的BPDU)
到根桥的最低路径成本(比较Cost值,越小越优)
最低的发送者网桥ID(这个比的就是对方的ID)
最低的发送者端口ID
每个段选择一个指定端口
在交换机之间的每个线路上选择一头作为指定端口
最低根桥ID(正常情况下,收到的BPDU)
到根桥的最低路径成本(比较Cost值,越小越优)
最低的发送者网桥ID(这个比的就是对方的ID)
最低的发送者端口ID
什么角色都没有的那个接口(也被称为非指定端口)进行阻塞
第一步:
sw1是根桥
第二步:
Sw2的e0/1是根端口
Sw3的e0/1是根端口
第三步:
Sw1的e0/1和e0/2是指定端口
Sw2的e0/2因为最低发送者网桥ID胜出,所以是指定端口
第四步:
Sw3的e0/2没有任何的角色,所以被阻塞,在思科设备中标注角色为Alternate
阻塞的接口
被判断为阻塞的接口会有以下特性:
不会从这个接口发送任何数据
这个接口不会学习任何的MAC地址
这个接口会监听BPDU信息,并且记录下来和其他接口收到的BPDU通过STP计算比较优劣
这个接口记录的BPDU会保存20s时间才会删除,每隔2s收到对方发送的BPDU都会重置20s计时器
如果20s都没有收到任何BPDU,这个接口就会尝试开启
端口状态
In the blocking state, ports can only receive BPDUs. It may take up to 20 seconds to change from this state;
In listening state, switches determine if there are any other paths to the root bridge. the forward delay and lasts for 15 seconds. In the listening state, user data is not being forwarded and MAC addresses are not being learned;
In learning state user data is not forwarded, but MAC addresses are learned from any traffic that is seen. The learning state lasts for 15 seconds and is also called the forward delay;
In forwarding state user data is forwarded and MAC addresses continue to be learned. BPDUs are still processed;
SW1(config)#vlan 10,20 SW1(config)#int range e0/0 -1 SW1(config-if-range)#sw tr en do SW1(config-if-range)#sw mo tr ================================== SW2(config)#vlan 10,20 SW2(config)#int range e0/0 -1 SW2(config-if-range)#sw tr en do SW2(config-if-range)#sw mo tr ================================== SW3(config)#vlan 10,20 SW3(config)#int range e0/0 -1 SW3(config-if-range)#sw tr en do SW3(config-if-range)#sw mo tr
VLAN0020 Spanning tree enabled protocol ieee Root ID Priority 32788 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 32788 (priority 32768 sys-id-ext 20) Address aabb.cc00.3000 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 15 sec
SW1(config)#spanning-tree vlan 10 root ? primary Configure this switch as primary root for this spanning tree secondary Configure switch as secondary root
primary
交换机会将优先级调整比现在的根桥还要低8192
secondary
交换机会将优先级调整比现在的根桥还要低4096
宏命令是一次性的,判定结束之后,就会生成一条修改优先级的命令
1 2
SW1#sh run | sec span spanning-tree vlan 10 priority 24576
RSTP
R6和R7作为观察者,配置IP地址,并且可以互相通信
SW4的e0/2接口设置为关闭状态,模拟没有这根线
1 2 3 4 5 6 7 8 9 10 11 12
R6(config)#int e0/0 R6(config-if)#ip add 192.168.67.6 255.255.255.0 R6(config-if)#no sh R7(config)#int e0/0 R7(config-if)#ip add 192.168.67.7 255.255.255.0 R7(config-if)#no sh R7#ping 192.168.67.6 repeat 100 Type escape sequence to abort. Sending 100, 100-byte ICMP Echos to 192.168.67.6, timeout is 2 seconds: .!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Success rate is 99 percent (99/100), round-trip min/avg/max = 1/1/6 ms
Switch(config)#int range e0/1-2 Switch(config-if-range)#spanning-tree portfast %Warning: portfast should only be enabled on ports connected to a single host. Connecting hubs, concentrators, switches, bridges, etc... to this interface when portfast is enabled, can cause temporary bridging loops. Use with CAUTION
%Portfast will be configured in 2 interfaces due to the range command but will only have effect when the interfaces are in a non-trunking mode.