Spanning Tree โ Root Election & Config
Spanning Tree Protocol prevents Layer 2 loops by electing one active path and blocking redundant links.
- The Root Bridge is elected based on the lowest Bridge ID (priority first, then MAC).
- The Root Port is the port with the lowest path cost toward the Root Bridge.
Facts
| Topic | Explanation |
|---|---|
| Problem | Broadcast storms, MAC flapping |
| Solution | Block redundant links |
| Root Bridge | Switch with the lowest Bridge ID |
| Bridge ID | Priority + MAC address |
| BPDU | Used for the STP calculation |
Priority values
0, 4096, 8192, 12288, 16384, 20480, 24576, 28672,
32768 (default), 36864, 40960, 45056, 49152, 53248, 57344, 61440
๐ Range: 0โ61440, step size 4096.
1. Root Bridge election
๐ The switch with the lowest Bridge ID wins. The Bridge ID = Bridge priority (most important) then MAC address (tie-breaker).
๐ Lowest wins โ not highest. Default priority is 32768; if all equal, the lowest MAC wins. That’s why you often set priority manually:
spanning-tree vlan 10 priority 4096
2. Root Port election (on non-root switches)
๐ Root Port = the port with the best path to root. Tie-break order:
- Lowest root path cost (sum of port costs toward root)
- Lowest sender Bridge ID
- Lowest sender port ID
๐ Every non-root switch has exactly one root port.
Quick overview
| Role | Rule |
|---|---|
| Root Bridge | Lowest priority โ lowest MAC |
| Root Port | Lowest path cost to root |
| Number of root ports | 1 per non-root switch |
| Root Bridge ports | All are Designated |
Classic CCNA traps โ ๏ธ
- โ “The fastest switch becomes root” โ wrong
- โ “The root is elected via IP” โ wrong
- โ “The root has a root port” โ wrong
- โ Priority beats MAC
Configuration
1) STP mode (global, cannot be mixed):
spanning-tree mode pvst
spanning-tree mode rapid-pvst
spanning-tree mode mst
2) Root election:
spanning-tree vlan 10 root primary
spanning-tree vlan 10 root secondary
! or manually (lower = better, steps of 4096):
spanning-tree vlan 10 priority 4096
spanning-tree vlan 20 priority 8192
! priority 0 works too if you really want it
3) Port cost (affects root port election, lower = preferred):
interface Gi0/1
spanning-tree vlan 10 cost 10
4) Port priority (tie-breaker, default 128, lower = better):
interface Gi0/1
spanning-tree vlan 10 priority 64
5) STP timers (classic 802.1D/PVST+ only โ RSTP/MST don’t use them actively):
spanning-tree vlan 10 hello-time 2
spanning-tree vlan 10 forward-time 15
spanning-tree vlan 10 max-age 20
6) MST basics (name + revision + mapping must match in the region):
spanning-tree mst configuration
name REGION1
revision 1
instance 1 vlan 10-20
instance 2 vlan 30-40
exit
7) MST root:
spanning-tree mst 1 root primary
spanning-tree mst 2 root secondary
! or: spanning-tree mst 1 priority 4096
8) Link type (RSTP/MST, rarely needed โ autodetected via duplex):
interface Gi0/1
spanning-tree link-type point-to-point
9) System-id extension (needed for PVST+/MST, usually on by default):
spanning-tree extend system-id
10) Show commands:
show spanning-tree
show spanning-tree vlan 10
show spanning-tree active
show spanning-tree summary
show spanning-tree mst configuration
show spanning-tree mst
Quick memory (without security)
- Mode first ยท root is decided by priority ยท cost before port-priority ยท timers = legacy ยท MST requires identical region data