STP - spanning-tree root primary command

One of the fundamental mechanisms of Spanning Tree Protocol (STP) is the election of a root bridge. Using the spanning-tree vlan x root primary command, it is possible to designate the local switch as the root bridge for the specified VLAN. Now what this command actually does is a little more involved than simply designating it the root bridge.

The spanning-tree root primary command in Cisco IOS operates by running a hardwired script that adjusts the switch's priority to make it the root bridge for a specified VLAN. The behavior of this command affects the priority values in various ways, depending on the IOS version and platform. According to the linked Cisco documentation below:

  1. IOS 15.X: The switch sets its priority to 24576 to become the root for the specified VLAN. If another switch has a lower priority, it sets its priority to 4096 less than the lowest priority.
  2. IOS 12.X: The command sets the bridge priority to 8192. If the switch does not become the root, the priority is adjusted to 100 less than the current root's priority. If it still does not become the root, an error occurs.
  3. Other Documentation: The primary keyword sets the priority to 24576, and the secondary keyword sets it to 28672.

In all cases, the command runs a script that examines the current root bridge and adjusts the local switch's priority to make it the root. This script runs only when the command is executed and does not automatically re-run if the network topology changes, meaning the command is not preemptive.

This behavior ensures that the local switch becomes or remains the root bridge when the command is executed. Depending upon the configuration found on other switches in the STP topology, this command may actually fail to fulfil its requirement, therefore it should be used cautiously, with a clear knowledge of the configuration found on other switches in the topology.

Links:

https://forum.networklessons.com/t/spanning-tree-root-bridge-configuration/13949/8?u=lagapidis.

https://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst2960/software/release/15-2_2_e/command/reference/cr_2960/cli3.html#pgfId-1947142

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/lanswitch/command/lsw-cr-book.pdf

https://www.ciscopress.com/articles/article.asp?p=2995351&seqNum=2

https://networklessons.com/spanning-tree/spanning-tree-root-bridge-configuration