Back to 2.0 Network Access

2.3 Spanning Tree Protocol

Preventing Layer 2 broadcast storms. Master Root Bridge elections, Rapid PVST+ optimizations, and critical edge-port security mechanisms.

Core Explanations

The Layer 2 Loop Problem

Redundancy is critical, but Layer 2 Ethernet headers do not have a TTL (Time to Live) field. If a physical loop exists between switches, broadcast frames will circulate endlessly, creating a Broadcast Storm that will melt the network in seconds. STP logically blocks redundant links to create a loop-free topology.

The Root Bridge Election

Switches elect a 'boss' switch called the Root Bridge using Bridge Protocol Data Units (BPDUs). The switch with the lowest Bridge ID (BID) wins. The BID is calculated by combining the Switch Priority (default 32768) + the Switch MAC Address.

Rapid PVST+ (802.1w)

Legacy STP (802.1D) could take 30 to 50 seconds to recover from a link failure. Cisco's default modern standard is Rapid Per-VLAN Spanning Tree Plus (Rapid PVST+), which provides sub-second convergence and runs a separate STP instance for every VLAN.

IOS Command Reference

Controlling the Root Bridge Election

! Method 1: The Macro (Automatically lowers priority)
SW1(config)# spanning-tree vlan 10 root primary
SW2(config)# spanning-tree vlan 10 root secondary

! Method 2: Manual Hardcoding (Must be multiples of 4096)
SW1(config)# spanning-tree vlan 10 priority 4096

! Upgrade protocol from legacy 802.1D to 802.1w
SW1(config)# spanning-tree mode rapid-pvst

Host Port Optimizations

SW1(config)# interface g0/1
! Bypasses listening/learning (For end devices ONLY)
SW1(config-if)# spanning-tree portfast

! Security: Err-disables the port if a BPDU is received
SW1(config-if)# spanning-tree bpduguard enable

Verification & Troubleshooting

SW1# show spanning-tree
! Shows the global STP status for VLAN 1
SW1# show spanning-tree vlan 10
! The most important command. Look for "This bridge is the root" to confirm your election victory.

CCNA Exam Gotchas

PortFast is DANGEROUS on Trunks

Never enable PortFast on a trunk link or a port connected to another switch. Because PortFast skips the STP listening/learning phases, a temporary loop can form instantly and crash the network. It is exclusively for end-device access ports.

The Default Priority Trap

If you do not manually set a Root Bridge, the switch with the lowest MAC address wins. MAC addresses are assigned sequentially at the factory, meaning your oldest, slowest switch will likely become the Root Bridge. Always hardcode your core switches as primary/secondary roots!

System EXT ID (VLAN ID)

Because Cisco uses PVST+, the switch actually adds the VLAN number to the base priority. If you leave the priority at default (32768) for VLAN 10, the actual priority shown in 'show spanning-tree' will be 32778 (32768 + 10).