How to Configure Spanning-Tree Protocol (STP)

Network loop can create a huge problem in a network. Routing protocols such as RIP and IGRP have their own techniques to stop network loops from occurring at the Network layer of the OSI model. Unfortunately, they (routing protocols) cannot be used to stop loops from occurring at the Data Link layer of the OSI model. If you have a network based on layer 2 switches and if the switches are interconnected using the redundant links, your network may suffer from the switching loops (network loops). But there is a protocol called Spanning-Tree Protocol (STP) that is used to stop switching loops in a layer 2 switched network.

STP helps to avoid the switching loops. It discovers all links in the network and shut down any redundant ones in order to prevent the network loops. STP elects a Root Bridge (switch) on the network through which it passes all the network traffic. The switch with the lowest MAC address becomes the root bridge if the priority of all the switches is set as default, which is 32678 plus number of VLANs. However, you can change the priority value of a switch to forcefully make it as a root bridge. The lower value means higher preference in the root bridge election.

The priority value can be any value from 0 to 61440. If you want that a switch should always be a root bridge, set its priority to zero (0). The priority value is set in increments of 4096. If you want to set a switch as the root bridge for every VLAN in your network, then you have to change the priority for each VLAN.

Configure Spanning-Tree Protocol Step by Step

We will use the following topology to explain the concept of Spanning-Tree Protocol.Spanning-Tree Protocol on Cisco Switch

In the preceding topology, first of all, we will find the root bridge. On the root bridge, you will find “This bridge is the root” message, and the root ID address and bridge ID address will be same.

  1. Open the console of Switch1 and execute the show spanning-tree command as shown in the following figure.show Spanning-Tree command
  2. In the preceding figure, you can see that Switch1 is not the root bridge because the addresses of Root ID and Bridge ID are different.
  3. Now, move on to Switch2, open the console of Switch2 and execute the show spanning-tree command as shown in the following figure.verify STP configuration
  4. In the preceding figure, you can see that Switch2 is also not the root bridge because the addresses of Root ID and Bridge ID are different.
  5. Now, move on to Switch3, open the console of Switch3 and execute the show spanning-tree command as shown in the following figure.how to show spanning-tree configuration
  6. In the preceding figure, you can see that Switch2 is the root bridge because the addresses of Root ID and Bridge ID are same, and it also shows the “This bridge is the root” message.

The above selection of the root bridge was based on MAC addresses because the priority of all the switches has set as default (32769). The MAC address (Bridge ID) of Switch3 (0007.EC61.51C2) was the lowest among all the switches, hence, it has become the root bridge.

Manually Selecting Root Bridge

As discussed earlier, you can also make a specific switch to act as a root bridge by changing its priority value. The following syntax is used to change the priority value of a switch.

Switch(config)#spanning-tree vlan <vlan number> priority <any value from 0 to 61440 but in multiple of 4096>
  1. In the following demonstration, we will make Switch1 as the root bridge manually for VLAN 1. For this, you need to lower down its priority value. Execute the following command to change the priority of Swicth1 from 32768 to 8192.
Switch1(config)#spanning-tree vlan 1 priority 8192

Alternatively, you can also use the following command to make Switch1 to acting as the root bridge.

Switch1(config)#spanning-tree vlan 1 root primary
  1. Since you have changed the priority value of Switch1, it should act as the root bridge. Execute the following command to verify the spanning-tree configuration.
Switch1#show spanning-tree
  1. In the preceding figure, you can see that after changing the priority value, Switch1 becomes the root bridge.manually selecting root bridge

In this post, we have learned how the spanning-tree protocol works and how to manually select a root bridge. If you have any queries regarding STP, let’s drop in the comment box, we will try to address them. Please also share the post to others.

Posted in Cisco, Switching Tagged with: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*