Root Bridge Election – Bridge ID, Priority, PVST+ & Security
1. What Is a Root Bridge and Why Does It Exist?
In any Layer 2 network with redundant switch links, there is a risk of broadcast storms — packets looping indefinitely because switches flood broadcasts out every port except the one they arrived on. Without loop prevention, a single broadcast frame would multiply exponentially, consuming all bandwidth within milliseconds.
Spanning Tree Protocol (STP, IEEE 802.1D) solves this by electing one switch as the Root Bridge — the logical centre of the Layer 2 topology. Every other switch then calculates the single best (lowest-cost) path to reach the Root Bridge and blocks all other redundant paths. The result is a loop-free tree topology rooted at the Root Bridge, with all blocked paths kept in standby ready to activate if the primary path fails.
Without STP — broadcast storm:
SW1 ---- SW2
| \/ | Broadcast enters SW1:
| /\ | SW1 floods to SW2 and SW3
SW3 ---- SW4 SW2 floods back to SW1, SW3, SW4
SW3 floods back to SW1, SW2, SW4
Frames multiply exponentially -- 100% bandwidth consumed
MAC table flaps -- network unusable within seconds
With STP -- loop-free tree:
SW1 (Root Bridge)
/ \
SW2 SW3
\ /
SW4 (one port BLOCKED)
SW4's blocked port stops the loop. If SW1-SW2 link fails,
the blocked port automatically unblocks to restore connectivity.
Related pages: STP Overview | VLANs | VLAN Tagging 802.1Q | RSTP (Rapid STP) Lab | PortFast & BPDU Guard | MAC Address Table | Root Bridge Configuration Lab | PortFast & BPDU Guard Lab
2. Bridge ID (BID) — Structure and Components
Every switch has a unique Bridge ID (BID) used for Root Bridge election. The BID is an 8-byte value composed of two fields: a 2-byte priority and a 6-byte MAC address. The switch with the lowest BID wins the election.
Bridge ID structure (8 bytes total): +------------------+-------------------+------------------------------+ | Bridge Priority | Extended Sys ID | MAC Address | | (4 bits) | (12 bits) | (6 bytes) | +------------------+-------------------+------------------------------+ | Bits 15-12 | Bits 11-0 | AA:BB:CC:DD:EE:FF | +------------------+-------------------+------------------------------+ Priority field (16 bits = 2 bytes) broken into two sub-fields: - 4-bit priority multiplier: valid values 0-15 (steps of 4096) - 12-bit Extended System ID: contains the VLAN number Example for VLAN 10 with priority 32768: Priority bits: 32768 / 4096 = 8 (binary: 1000) Extended Sys ID = 10 (VLAN 10 in decimal) Actual BID priority field = (8 x 4096) + 10 = 32778 Example for VLAN 1 with priority 32768: Actual BID priority field = 32768 + 1 = 32769 This is why default priority for VLAN 1 = 32769, not 32768!
| BID Component | Size | Default Value | Function |
|---|---|---|---|
| Bridge Priority | 4 bits (of the 2-byte priority field) | 32768 (binary: 1000 0000 0000 0000) | Administratively configurable; primary election criterion. Must be a multiple of 4096 (0–61440) |
| Extended System ID | 12 bits (of the 2-byte priority field) | VLAN number (e.g., 1 for VLAN 1) | Automatically added by the switch to identify the VLAN. This is why per-VLAN priorities differ by VLAN ID |
| MAC Address | 6 bytes (48 bits) | Switch's base MAC address (burned-in) | Tiebreaker when priorities are equal — lower MAC wins |
spanning-tree vlan 10 priority 32768, the actual priority shown
in show spanning-tree vlan 10 will be 32778 (32768 + 10).
For VLAN 1 it will show 32769. Always account for the VLAN ID addition
when calculating effective BID values.
3. Root Bridge Election — Step-by-Step Algorithm
The election begins when switches first connect and start exchanging BPDUs (Bridge Protocol Data Units). Every switch initially assumes it is the Root Bridge and advertises its own BID as the Root ID in its BPDUs. Switches update their view of the root as they receive BPDUs with lower BIDs.
Election algorithm:
Step 1: Every switch powers on and sends BPDUs claiming to be root.
BPDU contains: Root ID = own BID, Path Cost = 0, Sender BID = own BID
Step 2: Each switch compares received Root ID with its own BID.
If received Root ID is LOWER than current best root -> update root
Step 3: After the max-age timer (20 sec default), the switch with the
lowest BID is agreed upon as the Root Bridge.
Step 4: The Root Bridge sends Hello BPDUs every 2 seconds on all ports.
All other switches relay these BPDUs to their downstream neighbours.
Election decision:
Compare Priority first:
Lower priority number wins (e.g., 4096 beats 32768)
If priority is TIED:
Compare MAC address (lower MAC wins)
MAC: 0000.AAAA.AAAA beats 0000.BBBB.BBBB
Example election (4 switches, VLAN 1):
SW1: Priority 32769, MAC 0011.1111.1111 -> DROTHER
SW2: Priority 4097, MAC 0022.2222.2222 -> ROOT (lowest priority)
SW3: Priority 32769, MAC 0033.3333.3333 -> DROTHER
SW4: Priority 32769, MAC 0044.4444.4444 -> DROTHER
SW2 wins because 4097 < 32769 regardless of MAC addresses.
Election with Equal Priorities — MAC Tiebreaker
All four switches have default priority (VLAN 1 = 32769): SW1: Priority 32769, MAC 0011.1111.1111 -> ROOT (lowest MAC) SW2: Priority 32769, MAC 0022.2222.2222 SW3: Priority 32769, MAC 0033.3333.3333 SW4: Priority 32769, MAC 0044.4444.4444 SW1 wins because all priorities equal; SW1 has lowest MAC. This is dangerous in production -- the switch with lowest MAC (often oldest hardware) becomes root unintentionally. Always configure priority explicitly on your intended root!
4. Bridge Priority Configuration
Priority must be a multiple of 4096 (due to the 4-bit priority field). Valid values: 0, 4096, 8192, 12288, 16384, 20480, 24576, 28672, 32768, 36864, 40960, 45056, 49152, 53248, 57344, 61440.
! ── Method 1: Set explicit priority value ───────────────────────────────── ! Best for precise control; value shown in output = priority + VLAN ID Switch(config)# spanning-tree vlan 10 priority 4096 ! Effective BID priority = 4096 + 10 = 4106 Switch(config)# spanning-tree vlan 10 priority 0 ! Priority 0 guarantees this switch becomes root for VLAN 10 ! (0 + 10 = 10; no other switch can beat this unless also set to 0) ! ── Method 2: spanning-tree root macro (recommended) ───────────────────── ! Automatically sets priority to 24576 (primary) or 28672 (secondary) ! and adjusts timers. Cisco best practice for production. Switch(config)# spanning-tree vlan 10 root primary ! Sets priority to 24576 for VLAN 10 (or lower if current root has <= 24576) ! Effective: 24576 + 10 = 24586 Switch(config)# spanning-tree vlan 10 root secondary ! Sets priority to 28672 for VLAN 10 -- becomes root if primary fails ! Effective: 28672 + 10 = 28682 ! ── Verify priority configured ──────────────────────────────────────────── Switch# show spanning-tree vlan 10 | include Priority Bridge ID Priority 24586 (priority 24576 sys-id-ext 10) Root ID Priority 24586
| Priority Value | What It Means | When to Use |
|---|---|---|
| 0 | Absolute lowest — guarantees root status (effective = VLAN ID only) | When you must guarantee this switch is root regardless of any other switch; use carefully |
| 4096 | Very low — highly likely to be root | Primary root in multi-switch environments |
| 8192 | Low | Secondary root (backup if primary fails) |
| 24576 | Below default — set by root primary macro |
Cisco recommended for primary root bridge designation |
| 28672 | Slightly below default — set by root secondary macro |
Cisco recommended for secondary/backup root bridge |
| 32768 | Default — effective value = 32768 + VLAN ID (e.g., 32769 for VLAN 1) | Unmodified switch; random root election based on MAC |
| 61440 | Highest configurable — almost never becomes root | Explicitly prevent a switch from becoming root |
5. Root Bridge Placement — Impact on Traffic Flow
Where the Root Bridge is placed determines how traffic flows through the entire Layer 2 network. STP builds all paths relative to the Root Bridge, so placing it poorly causes traffic to take suboptimal routes.
Suboptimal root placement (root at access layer):
[Access-SW1] <-- ROOT
/ \
[Distribution-SW1] [Distribution-SW2]
\ /
[Core-Switch]
Problem: Traffic between servers (on Core) must travel UP to Access-SW1
(Root) and back DOWN -- wasting bandwidth on access-layer links.
Access switches have lower bandwidth (1G) while core has 10G/40G.
Optimal root placement (root at core/distribution):
[Core-Switch] <-- ROOT
/ \
[Distribution-SW1] [Distribution-SW2]
/ \ / \
[Access] [Access] [Access] [Access]
Traffic flows UP the tree (high-speed core links) and ACROSS.
Access-layer ports that lead AWAY from root get blocked --
these are lower-bandwidth links anyway, so correct behaviour.
6. PVST+ — Per-VLAN Root Bridge Election
Cisco's PVST+ (Per-VLAN Spanning Tree Plus) runs a separate, independent STP instance for each VLAN. This allows different VLANs to have different Root Bridges, enabling load balancing across redundant uplinks.
PVST+ Load Balancing Example:
Two core switches connected to two distribution switches:
SW-Core-A SW-Core-B
(Root VLAN10) (Root VLAN20)
/ \ / \
SW-Dist-1 SW-Dist-2-SW-Dist-3 SW-Dist-4
VLAN 10 tree: SW-Core-A is root
All VLAN 10 traffic flows through SW-Core-A
SW-Core-B ports for VLAN 10 are blocked
VLAN 20 tree: SW-Core-B is root
All VLAN 20 traffic flows through SW-Core-B
SW-Core-A ports for VLAN 20 are blocked
Result: Both uplinks carry traffic simultaneously
(for different VLANs) -- bandwidth is fully utilised!
! Configure SW-Core-A as root for odd VLANs, secondary for even:
SW-Core-A(config)# spanning-tree vlan 10,30,50 root primary
SW-Core-A(config)# spanning-tree vlan 20,40,60 root secondary
! Configure SW-Core-B as root for even VLANs, secondary for odd:
SW-Core-B(config)# spanning-tree vlan 20,40,60 root primary
SW-Core-B(config)# spanning-tree vlan 10,30,50 root secondary
! Verify per-VLAN root status:
SW-Core-A# show spanning-tree summary
Switch is in rapid-pvst mode
Root bridge for: Vlan0010 Vlan0030 Vlan0050
SW-Core-A# show spanning-tree vlan 10
VLAN0010
Spanning tree enabled protocol rstp
Root ID Priority 24586
Address 0011.1111.1111
This bridge is the root <-- confirms root status
...
| STP Variant | Root Elections | Load Balancing | Notes |
|---|---|---|---|
| STP (802.1D) | One per network (all VLANs share same tree) | Not possible | Single Common Spanning Tree (CST); one blocked port is blocked for ALL VLANs |
| PVST / PVST+ | One per VLAN | Yes — different roots per VLAN | Cisco proprietary; PVST+ adds 802.1Q trunk support; default on Cisco switches |
| RSTP (802.1w) | One per network | Not possible | Faster convergence than STP; same single-tree limitation |
| Rapid PVST+ (802.1w) | One per VLAN | Yes | Cisco default on modern switches; combines RSTP speed with PVST+ per-VLAN elections |
| MST (802.1s) | One per MST instance (groups of VLANs) | Yes — per instance | Most scalable; multiple VLANs share an instance; reduces BPDU overhead compared to PVST+ |
7. Verifying Root Bridge Status — show spanning-tree Output
! ── On the ROOT BRIDGE itself ──────────────────────────────────────────────
SW-Core-A# show spanning-tree vlan 10
VLAN0010
Spanning tree enabled protocol rstp
Root ID Priority 24586
Address 0011.1111.1111
This bridge is the root <-- KEY: confirms this is root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 24586 (priority 24576 sys-id-ext 10)
Address 0011.1111.1111
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- ----
Gi0/1 Desg FWD 4 128.1 P2p
Gi0/2 Desg FWD 4 128.2 P2p
! Root bridge: ALL ports are DESIGNATED (Desg) -- root never has root ports
! ── On a NON-ROOT switch ───────────────────────────────────────────────────
SW-Access-1# show spanning-tree vlan 10
VLAN0010
Spanning tree enabled protocol rstp
Root ID Priority 24586
Address 0011.1111.1111 <-- Root bridge MAC (NOT this switch)
Cost 4 <-- Path cost to reach root
Port 1 (GigabitEthernet0/1) <-- Port facing root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address 0044.4444.4444 <-- THIS switch's MAC
...
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- ----
Gi0/1 Root FWD 4 128.1 P2p <-- faces root bridge
Gi0/2 Altn BLK 4 128.2 P2p <-- BLOCKED (alternate)
Gi0/3 Desg FWD 4 128.3 P2p <-- faces downstream switch
! Interpreting output:
! Root ID section: shows who the root is (MAC + priority)
! Bridge ID section: shows THIS switch's own BID
! If Root ID MAC = Bridge ID MAC: THIS switch IS the root
! If "This bridge is the root" appears: confirms root status
! Port roles: Root (best path to root), Desg (root-facing downstream),
! Altn (blocked backup), Bkup (blocked redundant on same segment)
Key show spanning-tree Commands
Switch# show spanning-tree ! All VLANs summary Switch# show spanning-tree vlan 10 ! Detailed for VLAN 10 Switch# show spanning-tree vlan 10 detail ! Very verbose -- all port details Switch# show spanning-tree summary ! Which VLANs this switch is root for Switch# show spanning-tree root ! Root bridge info for all VLANs (table) Switch# show spanning-tree interface Gi0/1 ! STP status for one interface
8. Root Bridge Election During Network Changes
The Root Bridge election is not a one-time event — it can re-trigger whenever the network topology changes.
| Trigger Event | What Happens | Impact |
|---|---|---|
| New switch joins with lower BID | The new switch sends superior BPDUs; existing switches update their root view; new switch becomes root | Full STP reconvergence — ports transition through Blocking → Listening → Learning → Forwarding (up to 50 sec in classic STP; ~1 sec in RSTP) |
| Current Root Bridge fails | Remaining switches stop receiving Hello BPDUs; after Max Age timer (20 sec), they declare root as lost and hold a new election | Network disruption during the Max Age + convergence period (up to 50+ sec in STP; faster in RSTP) |
| Priority manually changed | Switch sends new BPDUs with updated priority; if new priority is lower than current root, election re-runs | Controlled reconvergence — schedule changes during maintenance windows |
| Link failure on non-root switch | Affected switch recalculates paths to root; may trigger a port state change but not a new root election (root is still present) | Local reconvergence on affected switch only |
9. RSTP and Root Bridge Election
RSTP (Rapid Spanning Tree Protocol, 802.1w) uses the same Root Bridge election algorithm as classic STP — lowest BID wins — but dramatically accelerates the convergence process after the election.
| Feature | STP (802.1D) | RSTP (802.1w) |
|---|---|---|
| Election algorithm | Lowest BID wins | Identical — lowest BID wins |
| BPDU origination | Only Root Bridge originates BPDUs; others relay | Every switch originates BPDUs every 2 sec |
| BPDU version field | Version 0 | Version 2 |
| Convergence time | 30–50 seconds | 1–2 seconds (proposal/agreement mechanism) |
| Port states | Blocking, Listening, Learning, Forwarding, Disabled | Discarding, Learning, Forwarding (3 states) |
| Port roles | Root, Designated, Blocked | Root, Designated, Alternate, Backup, Disabled |
| Failure detection | Max Age timer (20 sec) | 3 missed Hello intervals (6 sec) |
See RSTP (Rapid STP) Lab for detailed coverage of the proposal/agreement mechanism and port role differences.
10. Security — Root Guard and BPDU Guard
The Root Bridge election mechanism can be exploited by an attacker who connects a switch with a lower BID, causing a rogue switch to be elected Root Bridge. This redirects all Layer 2 traffic through the attacker's switch, enabling man-in-the-middle attacks.
Rogue Root Bridge attack:
SW-Core (Priority 4097) -- legitimate Root Bridge
|
SW-Distribution
| |
SW-Access [Attacker's switch: Priority 0] <-- plugged into access port
^
Sends BPDUs with Priority 0 claiming to be root
All traffic redirects through attacker's switch
Attacker captures data in transit
Root Guard
Root Guard prevents a port from ever becoming a Root Port — it will never accept a superior BPDU that would make the connected switch the new Root Bridge. If a superior BPDU is received, the port is placed in a root-inconsistent state (effectively blocking) and generates a syslog message.
! Enable Root Guard on distribution-facing ports ! (ports that should NEVER receive superior BPDUs from a new root) Switch(config)# interface GigabitEthernet0/1 Switch(config-if)# spanning-tree guard root ! Verify Root Guard status: Switch# show spanning-tree inconsistentports Name Interface Inconsistency ----------------------- ---------------------- ------------------ VLAN0010 GigabitEthernet0/1 Root Inconsistent ! The port is blocking (protecting the topology) ! When the superior BPDUs stop, the port automatically recovers
BPDU Guard
BPDU Guard is used on PortFast-enabled access ports (ports connected to end devices like PCs and printers that should never receive BPDUs). If any BPDU is received on a BPDU Guard port, the port is immediately placed in an err-disabled state (shut down). This prevents a rogue switch from connecting to an access port and influencing STP.
! Enable BPDU Guard globally on all PortFast ports: Switch(config)# spanning-tree portfast bpduguard default ! Enable BPDU Guard on a specific interface: Switch(config)# interface GigabitEthernet0/10 Switch(config-if)# spanning-tree bpduguard enable ! Verify err-disabled ports: Switch# show interfaces status err-disabled Port Name Status Reason Err-disabled Vlans Gi0/10 err-disabled bpduguard ! Re-enable after resolving the cause: Switch(config)# interface GigabitEthernet0/10 Switch(config-if)# shutdown Switch(config-if)# no shutdown
| Feature | Root Guard | BPDU Guard |
|---|---|---|
| Protects against | Rogue root bridge on uplink/trunk ports | Rogue switch on access/PortFast ports |
| Triggers on | Superior BPDU received (would change root) | Any BPDU received (even inferior) |
| Port action | Port enters root-inconsistent state (blocking) | Port enters err-disabled state (shutdown) |
| Recovery | Automatic — recovers when superior BPDUs stop | Manual — requires shutdown / no shutdown
(or auto-recovery timer) |
| Applied to | Designated ports facing potential rogue roots (distribution, access uplinks) | Access ports with PortFast (connected to PCs, printers — never switches) |
11. Troubleshooting Root Bridge Issues
| Symptom | Likely Cause | Diagnostic Command | Fix |
|---|---|---|---|
| Wrong switch is Root Bridge | Priority not configured on intended root; default priority (32768) on all switches leaves election to lowest MAC address | show spanning-tree vlan [id] — check
Root ID MAC and compare to intended root |
spanning-tree vlan [id] root primary
on intended root switch |
| Suboptimal traffic paths (traffic using slow links) | Root Bridge is in access/distribution layer instead of core; STP builds paths toward wrong location | show spanning-tree vlan [id] — check
Root ID; trace path using Root Port chain |
Move root to core switch; configure per-VLAN roots with PVST+ for load balancing |
| Root Bridge keeps changing (flapping) | Unstable link to current root; rogue switch advertising lower BID; misconfigured priority | debug spanning-tree events;
show logging for topology change messages |
Enable Root Guard on appropriate ports; check cabling; verify no unauthorised switches connected |
| Port stuck in root-inconsistent state | Root Guard triggered — superior BPDUs arriving on a Root Guard port | show spanning-tree inconsistentports |
Investigate source of superior BPDUs; remove rogue switch; Root Guard auto-recovers when BPDUs stop |
| Port stuck in err-disabled | BPDU Guard triggered — BPDU received on PortFast port (switch connected to access port) | show interfaces status err-disabled |
Remove the switch from the access port; fix the cause;
shutdown / no shutdown on the port to restore |
12. Complete Configuration Example — Core/Distribution/Access
! Topology: Core switch (SW-Core), two Distribution switches (SW-Dist-1, SW-Dist-2),
! two Access switches (SW-Access-1, SW-Access-2)
! Goal: SW-Core is root for all VLANs; SW-Dist-1 is secondary root
! ── SW-Core: Primary Root for all VLANs ───────────────────────────────────
SW-Core(config)# spanning-tree mode rapid-pvst
SW-Core(config)# spanning-tree vlan 1,10,20,30 root primary
! Sets priority 24576 for each VLAN (effective: 24577/24586/24596/24606)
! Enable Root Guard on downlink ports (no superior BPDUs should come from
! distribution/access switches)
SW-Core(config)# interface range GigabitEthernet0/1 - 4
SW-Core(config-if-range)# spanning-tree guard root
! ── SW-Dist-1: Secondary Root for all VLANs ───────────────────────────────
SW-Dist-1(config)# spanning-tree mode rapid-pvst
SW-Dist-1(config)# spanning-tree vlan 1,10,20,30 root secondary
! Sets priority 28672
! ── SW-Access-1: PortFast and BPDU Guard on host ports ────────────────────
SW-Access-1(config)# spanning-tree mode rapid-pvst
! Enable PortFast and BPDU Guard on all access host ports:
SW-Access-1(config)# interface range FastEthernet0/1 - 24
SW-Access-1(config-if-range)# switchport mode access
SW-Access-1(config-if-range)# spanning-tree portfast
SW-Access-1(config-if-range)# spanning-tree bpduguard enable
! ── Verify from SW-Core ────────────────────────────────────────────────────
SW-Core# show spanning-tree summary
Switch is in rapid-pvst mode
Root bridge for: Vlan0001 Vlan0010 Vlan0020 Vlan0030
SW-Core# show spanning-tree vlan 10
VLAN0010
Root ID Priority 24586
Address aabb.cc00.0100
This bridge is the root
SW-Core# show spanning-tree root
Root Hello Max Fwd
Vlan Root ID Cost Time Age Dly Root Port
Vlan0001 24577 aabb.cc00.0100 0 2 20 15
Vlan0010 24586 aabb.cc00.0100 0 2 20 15
Vlan0020 24596 aabb.cc00.0100 0 2 20 15
13. Key Points & Exam Tips
- Root Bridge election = lowest BID wins. BID = Priority + Extended System ID + MAC. Priority compared first; MAC is tiebreaker only when priorities are equal.
- Extended System ID: VLAN number is added to the priority field. Default priority for VLAN 1 = 32769 (32768 + 1). For VLAN 10 = 32778 (32768 + 10). This is the most common exam calculation trap.
- Priority must be a multiple of 4096: Valid values are 0, 4096, 8192 ... 61440. Setting any other value is rejected by Cisco IOS.
- Use
spanning-tree vlan [id] root primary(sets 24576) androot secondary(sets 28672) for clean production configuration. - Root Bridge has ALL designated ports — it never has a Root Port (there is no "path to itself"). If you see a Root Port on a switch, that switch is NOT the root.
- PVST+ runs independent elections per VLAN — enables load balancing by assigning different VLANs to different root bridges.
- RSTP uses the same election algorithm as STP but every switch originates BPDUs (not just the root) and failure detection uses 3 × Hello interval (6 sec) instead of Max Age (20 sec).
- Root Guard → used on trunk/designated ports facing possible rogue roots; places port in root-inconsistent (blocking) state on superior BPDU; auto-recovers. BPDU Guard → used on access PortFast ports; places port in err-disabled on ANY BPDU; requires manual recovery.
- Verify with:
show spanning-tree vlan [id],show spanning-tree summary,show spanning-tree root,show spanning-tree inconsistentports. - Root placement best practice: Core layer switch = root; distribution switch = secondary root. Never let access-layer switches become root.
Related pages: STP Overview | STP Port States | STP BPDUs | RSTP Lab | PortFast & BPDU Guard | MAC Address Table | Root Bridge Config Lab | PortFast & BPDU Guard Lab