Friday 5 February 2010

Spanning Tree Protocol

In this post I'll be checking that Spanning Tree is working correctly between Switch1 and Switch2. Finally I will configure the non-Root Bridge as the Root and verify the configuration.

The switches are connected as shown in the diagram below.




I check the switches to determine which is the root switch.

switch1#show spanning-tree root

Root Hello Max Fwd
Vlan Root ID Cost Time Age Dly Root Port
---------------- -------------------- --------- ----- --- --- ------------
VLAN0001 32769 000c.8582.c600 0 2 20 15
VLAN0002 32770 000c.8582.c600 0 2 20 15
switch1#show spanning-tree summary
Root bridge for: VLAN0001, VLAN0002.
Extended system ID is enabled.
PortFast BPDU Guard is disabled
EtherChannel misconfiguration guard is enabled
UplinkFast is disabled
BackboneFast is disabled
Default pathcost method used is short

Name Blocking Listening Learning Forwarding STP Active
---------------------- -------- --------- -------- ---------- ----------
VLAN0001 0 0 0 4 4
VLAN0002 0 0 0 2 2
---------------------- -------- --------- -------- ---------- ----------
2 vlans 0 0 0 6 6



I can see this (Switch1) is the root bridge for both VLANs. As this is the root bridge I check a non-root bridge (Switch2) to see which ports are in blocking mode.

switch2#sh spanning-tree blockedports

Name Blocked Interfaces List
-------------------- ------------------------------------
VLAN0001 Fa0/24
VLAN0002 Fa0/24

Number of blocked ports (segments) in the system : 2


From the output I can determine that port Fa0/24 on Switch2 is in blocking mode.






To test Spanning Tree is working I ping Switch2 from a PC connected to Switch1 and disconnect the uplink on fa0/1

MacBook:~ syn$ ping 10.0.1.211
PING 10.0.1.211 (10.0.1.211): 56 data bytes
64 bytes from 10.0.1.211: icmp_seq=0 ttl=255 time=22.273 ms
64 bytes from 10.0.1.211: icmp_seq=1 ttl=255 time=4.341 ms
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
--------cut----------
Request timeout for icmp_seq 27
Request timeout for icmp_seq 28
Request timeout for icmp_seq 29
Request timeout for icmp_seq 30
Request timeout for icmp_seq 31
Request timeout for icmp_seq 32
64 bytes from 10.0.1.211: icmp_seq=33 ttl=255 time=4.376 ms
64 bytes from 10.0.1.211: icmp_seq=34 ttl=255 time=4.117 ms
64 bytes from 10.0.1.211: icmp_seq=35 ttl=255 time=4.111 ms
^C
--- 10.0.1.211 ping statistics ---
36 packets transmitted, 5 packets received, 86.1% packet loss
round-trip min/avg/max/stddev = 4.111/7.844/22.273/7.216 ms

As can be seen from the ping results it takes 30 seconds for STP to converge and failover to port Fa0/24

switch2#sh spanning-tree root

Root Hello Max Fwd
Vlan Root ID Cost Time Age Dly Root Port
---------------- -------------------- ------ ----- --- --- ----------------
VLAN0001 32769 000c.8582.c600 19 2 20 15 Fa0/24
VLAN0002 32770 000c.8582.c600 19 2 20 15 Fa0/24


Reconnecting the uplink cable causes STP to failover back to the Fa0/1 because Fa0/1 has the lowest priority.

To view detailed information about Spanning Tree on a ports use the following show command.


switch2#show spanning-tree active detail
------cut---------
Port 24 (FastEthernet0/24) of VLAN0002 is blocking
Port path cost 19, Port priority 128, Port Identifier 128.24.
Designated root has priority 32770, address 000c.8582.c600
Designated bridge has priority 32770, address 000c.8582.c600
Designated port id is 128.24, designated path cost 0
Timers: message age 2, forward delay 0, hold 0
Number of transitions to forwarding state: 4
Link type is point-to-point by default
BPDU: sent 8, received 8232


Here I can see the ports priority details, timers and how many times the port has transitioned into a forwarding state.


To configure Switch2 as the Root Bridge for both VLAN's I use the following command.

switch2(config)#spanning-tree vlan 1-2 root primary


I verify this with the following show command.

switch2#show spanning-tree summary
Switch is in pvst mode
Root bridge for: VLAN0001-VLAN0002
EtherChannel misconfiguration guard is enabled
Extended system ID is enabled
Portfast is disabled by default
PortFast BPDU Guard is disabled by default
Portfast BPDU Filter is disabled by default
Loopguard is disabled by default
UplinkFast is disabled
BackboneFast is disabled
Pathcost method used is short

Name Blocking Listening Learning Forwarding STP Active
---------------------- -------- --------- -------- ---------- ----------
VLAN0001 0 0 0 3 3
VLAN0002 0 0 0 3 3
---------------------- -------- --------- -------- ---------- ----------
2 vlans 0 0 0 6 6


Switch1 being the non-Root Bridge now has interfaces in blocking state.

switch1#show spanning-tree blockedports

Name Blocked Interfaces List
-------------------- ------------------------------------
VLAN0001 Fa0/24
VLAN0002 Fa0/24

Number of blocked ports (segments) in the system : 2