In most networks, the root bridge of the spanning tree topology should be placed on the most central core switch of the network.
Switches by default use a priority of 32,768 meaning that without adjustment the root bridge election is going to be assigned to a switch with the lowest MAC address. This does not guarantee that it will be the core switch of the network and may result in an in-stable topology.
To force a particular switch on the network to become the root bridge, it’s priority number must be lowered. The lower the priority value a switch is, the more likely it is going to become the root bridge of that spanning tree topology. There are two common commands to accomplish this:
spanning-tree vlan X priority Y, X representing the VLAN number and priority representing a priority value in increments of 4096.
spanning-tree vlan X root primary, X representing the VLAN number. This will force the switch on that network to become the root bridge of that VLAN by lowering its value to one set of 4096 lower than the existing priority on the spanning-tree topology.
Primary can be replaced with
secondary to set the network switch to be the backup root bridge in case the primary ever fails.
There is an additional
diameter suffix command that allows to tune the STP topology modifying it’s timers and convergence times. The value after the diameter suffix should specify the maximum number of hops between the furthest switch and the root bridge.
For the best protection of the STP topology to not go to incorrect switches, setting the primary root priority to 0 and the secondary to 4096 will greatly help prevent other switches from taking control of the STP topology.