← All network notes

Switching (L2) ยท CCNA + CCNP

Spanning Tree โ€” Root Election & Config

Spanning Tree Protocol prevents Layer 2 loops by electing one active path and blocking redundant links.

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:

  1. Lowest root path cost (sum of port costs toward root)
  2. Lowest sender Bridge ID
  3. 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 โš ๏ธ

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)