Sub topic 16
Placing the root bridge on purpose
This chapter assumes you know how the root bridge is elected (lowest bridge ID wins), how path cost works, and how to read show spanning-tree output. Here you decide which switch becomes the root instead of leaving it to chance.
Why default election goes wrong
Every switch ships with the same default priority, 32768. When priorities tie, the lowest MAC address wins. That is usually the oldest switch, which is often a small access switch in a closet. If that switch becomes root, traffic between distribution switches may detour through it.
The root also determines every other switch's root path cost. A poorly placed root produces long paths and blocks the wrong links.
Where the root belongs
Place the root at the center of the Layer 2 topology. In a typical campus design, that is a distribution or core switch. Pick a second switch as the backup root, and make it adjacent to the primary root so failover keeps paths short.
In this layout, each access switch has one root port toward Dist-1 and a blocked or alternate port toward Dist-2. If Dist-1 fails, Dist-2 takes over and the tree barely changes.
Setting the priority
Priority is part of the bridge ID. It must be a multiple of 4096, because the lower 12 bits carry the VLAN ID (the extended system ID). You have two ways to set it.
root primaryis a macro that sets the priority low enough to win, normally 24576. If another switch already has a lower priority, the macro goes lower, down to 4096.prioritysets an exact value. This is more predictable, because the macro's result depends on what it sees at that moment.
! Primary root for VLAN 10
configure terminal
spanning-tree mode rapid-pvst
spanning-tree vlan 10 priority 4096
end
! Backup root for VLAN 10
configure terminal
spanning-tree mode rapid-pvst
spanning-tree vlan 10 priority 8192
endWith per-VLAN spanning tree you can balance load. Make Dist-1 root for VLAN 10 and Dist-2 root for VLAN 20. Each distribution switch then carries one VLAN's traffic, and each backs up the other.
Verifying and protecting the choice
Check the result with show spanning-tree vlan 10. On the root, the output says "This bridge is the root". On other switches, the root port points toward the intended switch.
A setting only holds if nobody can override it. A newly attached switch with priority 0 would take over as root. Apply Root Guard on ports facing switches that must never become root, as covered in the protection chapter.
Exercise
A distribution switch has priority 4096 for VLAN 10. You run spanning-tree vlan 10 priority 4100 and the command is rejected. Why, and what values are accepted?
Show answer
The priority must be a multiple of 4096, because the lower 12 bits of the priority field hold the VLAN ID. Valid values are 0, 4096, 8192, and so on up to 61440.
Exercise
Why configure a backup root with a priority such as 8192 instead of leaving it at the default?
Show answer
With the default 32768, a failure of the primary root could let any switch with a lower MAC address win the election. A priority of 8192 makes the chosen backup win, so the new tree stays centered.