Pcornel
Networking · Switching

STP (Spanning Tree Protocol)

Cheat sheet · https://pcornel.dk/topic.php?topic=605

Back to the Topic

Answer

Spanning tree (802.1D, and its faster versions RSTP and MST) prevents Layer 2 loops by electing one root bridge, choosing one best path from every switch to the root, and blocking the redundant ports. Cisco runs a separate tree per VLAN (PVST+ / Rapid PVST+) by default.

Remember

Election order: lowest bridge ID wins root; each non-root switch picks the port with the lowest cost to the root (root port); each segment has one designated port; the rest block. Tie-breakers: root path cost, sender bridge ID, sender port priority, sender port number. Place the root deliberately with priority — never leave it to the lowest MAC address.

First checks

  • show spanning-tree vlan <id> — root ID, local bridge ID, and each port's role, state and cost.
  • show spanning-tree root — the root bridge, root cost and root port per VLAN.
  • show spanning-tree vlan <id> detail — BPDUs sent and received, topology changes and their source.
  • show spanning-tree summary — mode, enabled features and port counts per state.
  • show spanning-tree inconsistentports — ports blocked by root guard, loop guard or type inconsistency.

Commands

show spanning-tree vlan <vlan>
Which VLAN/instance is affected?
show spanning-tree root
Who is root?
show spanning-tree inconsistentports
Is a guard feature intervening?
show spanning-tree vlan <id>
show interfaces status err-disabled
show spanning-tree

Verify in this order

bridge IDs compared → root elected → each switch picks its lowest-cost root port → one designated port per segment → remaining ports block → loop-free forwarding tree per VLAN

Where it usually breaks

physical link → switchport/bundle membership → VLAN/instance state → STP/LAG decision → MAC forwarding → end-to-end frame path

STP roles and forwarding states

ItemMeaning
Root bridgeLowest Bridge ID wins the election
Root portBest path toward the root on a non-root switch
Designated portForwarding port selected for a segment
Alternate portRedundant path kept non-forwarding to avoid loops
DiscardingDoes not forward user frames
LearningLearns source MAC addresses but does not yet forward user frames
ForwardingLearns and forwards user traffic

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=605

Confirmation

Confirm action

Continue?