Sub topic 4
Electing the root bridge
This chapter assumes you know how BPDUs carry the bridge ID, and that you can read basic switch CLI output. It covers how switches use that information to agree on one root bridge.
The rule: lowest bridge ID wins
Every switch starts out believing it is the root. Each one sends BPDUs that name itself as root. When a switch receives a BPDU that advertises a lower root bridge ID than the one it currently believes in, it adopts the new root. It then relays that better information on its other ports.
The bridge ID is compared as one number: priority first, then MAC address. The MAC address only breaks ties between equal priorities. Per-VLAN spanning tree adds the VLAN number to the priority, so the priority field is 32768 plus the VLAN ID by default.
Worked example
Three switches run VLAN 10 with these values:
| Switch | Priority | Extended system ID | MAC address | Bridge priority shown |
|---|---|---|---|---|
| SW1 | 32768 | 10 | 0000.0c00.0001 | 32778 |
| SW2 | 32768 | 10 | 0000.0c00.0002 | 32778 |
| SW3 | 4096 | 10 | 0000.0c00.0003 | 4106 |
SW3 wins because 4106 is lower than 32778. Its higher MAC address does not matter, since priority is compared first. If SW3 were absent, SW1 would win the tie on its lower MAC address.
What happens after the election
The election is not a one-time event. The root sends a BPDU every hello interval (2 seconds by default), and the other switches relay it. If a switch stops hearing the root's BPDUs for max age (20 seconds by default), it starts a new election.
A new switch with a lower bridge ID takes over as soon as its BPDUs arrive. This is why a switch plugged in with a low priority or a low MAC address can silently become the root. The tree then re-forms around it.
Influencing the result
Do not leave the outcome to MAC addresses. The oldest switch usually has the lowest MAC address, and it is often a poor choice for the root. Lower the priority on the switch you want instead.
! Cisco IOS: use Rapid PVST+ and make this switch the root for VLAN 10
configure terminal
spanning-tree mode rapid-pvst
spanning-tree vlan 10 root primary
end
! Or set the priority explicitly (must be a multiple of 4096)
configure terminal
spanning-tree vlan 10 priority 4096
endThe root primary macro sets the priority just low enough to beat the current root. It usually picks 24576, or 4096 less than the current root's priority if that is lower. It is not a permanent guarantee, because another switch can later be configured with a lower value.
Check the result with show spanning-tree vlan 10. The line "This bridge is the root" appears on the winner. On other switches, the Root ID section shows the root's priority and address.
Exercise
Switch A has priority 8192 and MAC 00aa.0000.0009. Switch B has priority 8192 and MAC 00aa.0000.0002. Switch C has priority 4096 and MAC 00aa.0000.00ff. Which switch is the root? Which would be root if C were removed?
Show answer
Switch C is the root because its priority of 4096 is lowest. Without C, A and B tie on priority, so B wins with the lower MAC address.