How-to: Configure spanning tree protocol (STP) Part1

As we mentioned in one of our previous posts, STP was developed to allow redundancy in the L2 network while maintaining a loop free network. Today we are going to discover how STP is actually doing this function.

Step1: Electing the root bridge

What is the root bridge?

The root bridge is the master bridge of the spanning tree which all paths calculations are based upon. Each switch must have an active path to the root bridge. All bridges in the same domain must agree on the same root.The root bridge has all its ports in the forwarding state. All traffic passing from one segment to another in the network must pass the root bridge.

How is the root bridge elected?

The Bridge ID is used to determine the root bridge. The BID is a combination of the priority value (default:32768) and the MAC address of the switch. The rule is, the lower the BID the better. The lowest bridge ID becomes the root bridge.

If two or more switches happen to have the same priority (i.e. default value) the MAC address is used as a tie breaker; The bridge with the lowest MAC address becomes the root of the tree.

How to manipulate the root bridge election?

By default Cisco switches run a separate STP instance for every VLAN configured on the switch; this mode is called PVST.

In the digram below I am going to configure Switch1 as a root switch for the default VLAN (1) using two methods.

Root bridge may be elected using one of the following methods:

  • Election by chance: you can leave STP to do its work without even knowing about it. By default each bridge comes with a default priority value of 32768. In such case the bridge with the lowest MAC address will become the root bridge. This method is not recommended except in very simple network topologies.
  • Setting the Bridge priority using the command spanning-tree vlan [list] priority [value]. The list defines the instances that the new priority value applies to.
Switch1(config)#do debug spanning-tree root
Switch1(config)#spanning-tree vlan 1 priority 4096
01:17:58: STP: VLAN0001 we are the spanning tree root

  • Using the command spanning-tree vlan [list] root [primary | secondary]. Using this command will automatically lower the priority of the switch to a very significant value in order to make sure that the switch is elected as a root switch.
Switch1(config)#spanning-tree vlan 1 root primary
01:20:59: STP: VLAN0001 we are the spanning tree root

!-- Priority is lowered automatically as shown in the output below

Switch1(config)#do show spanning-tree vlan 1    

  Spanning tree enabled protocol ieee
  Root ID    Priority    24577
             Address     001b.90b4.6900
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    24577  (priority 24576sys-id-ext 1)
             Address     001b.90b4.6900
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 15

finally I have some links for you if you need to look for more information:

  • STP configuration guide.
  • This is a detailed great post written by Petr Lapukhov explaining PVST+ explaining almost all you need to know about PVST+.

Check Also

Best AI tools list