Use it when checking loop prevention, root placement or edge-port protection on a switch.
STP (Spanning Tree Protocol) · Layer 2 Switch
On a Layer 2 switch, Spanning Tree Protocol blocks redundant paths so the switched network has no loops while keeping backup links ready to forward if the active path fails.
1. On L2 switches STP blocks redundant paths.
2. Use Rapid PVST+.
3. Set root deliberately.
4. PortFast + BPDU guard on edge.
5. Monitor topology changes.
BPDUs → root → roles → loop-free
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Effective-state and workload closure Verify boundary
Compare root ID, cost, role and state on both ends; validate VLAN/MST mapping and MAC movement for the test host, then test the original Layer-2 flow.
Step 2 Common mistakes Narrow the fault
- No defined root bridge, letting the oldest switch become root.
- Disabling STP to fix a problem.
Step 3 Where it fails Narrow the fault
Walk physical link → switchport/bundle membership → VLAN/instance state → STP/LAG decision → MAC forwarding → end-to-end frame path and stop where observed state diverges.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- STP prevents Layer 2 loops by blocking redundant paths.
- Rapid PVST+ and MST are the common modern variants.
- Set the root bridge deliberately.
show spanning-tree summary— mode, rootshow spanning-tree vlan <vlan>— roles
ReferenceWhat it is1 section · depth on demand
What it is
STP/RSTP/MST receives BPDUs per port/VLAN or instance, elects a root and root path, assigns port roles, and places ports into forwarding/discarding states. RSTP proposal/agreement accelerates transition, while MST maps VLANs to instances.
ReferenceWhy it matters1 section · depth on demand
Overview
STP on access switches: Rapid PVST+ or MST, the access switch should never become root (set root on distribution: spanning-tree vlan 1-4094 root primary), and edge ports use PortFast + BPDU Guard.
spanning-tree mode rapid-pvst
spanning-tree portfast default
spanning-tree portfast bpduguard default
show spanning-tree root
show spanning-tree inconsistentports
ReferenceImportant terms & boundaries3 sections · depth on demand
In depth
Spanning Tree on a Layer 2 switch
Spanning Tree Protocol prevents Layer 2 loops while keeping redundant links. Cisco's Catalyst 9000 STP guide describes it as ensuring a single active path between any two stations, transparently to end devices. Rapid PVST+ is the default mode, with one instance per VLAN.
Root bridge election (STP guide)
| Element | Detail |
|---|---|
| Bridge ID | 4-bit priority + 12-bit extended system ID (VLAN) + MAC address |
| Default priority | 32768; lowest wins; ties go to the lowest MAC |
root primary | Sets 24576 if that makes the switch root |
root secondary | Sets 28672 |
| Valid priorities | Multiples of 4096 from 0 to 61440 |
Port roles (STP guide)
| Role | Meaning |
|---|---|
| Root port | Best path to the root on a non-root switch |
| Designated port | Forwarding port elected for each segment |
| Alternate port | Blocked; alternate path to the root |
| Backup port | Blocked; in a loopback configuration |
Default path costs and timers (STP guide)
| Speed | Cost |
|---|---|
| 1 Gbit/s | 20000 |
| 10 Gbit/s | 2000 |
| 40 Gbit/s | 500 |
| 100 Gbit/s | 200 |
Timers: hello 2 s, forward delay 15 s, max age 20 s.
DIST1(config)# spanning-tree mode rapid-pvst
DIST1(config)# spanning-tree vlan 110,120 root primary
DIST2(config)# spanning-tree vlan 110,120 root secondary
SW1(config)# interface range GigabitEthernet1/0/1 - 46
SW1(config-if-range)# spanning-tree portfast
SW1(config-if-range)# spanning-tree bpduguard enable
SW1# show spanning-tree vlan 110
VLAN0110
Spanning tree enabled protocol rstp
Root ID Priority 24686
Address a4bb.6d10.0100
Cost 2000
Port 49 (TenGigabitEthernet1/1/1)
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Te1/1/1 Root FWD 2000 128.49 P2p
Te1/1/2 Altn BLK 2000 128.50 P2p
Gi1/0/5 Desg FWD 20000 128.5 P2p Edge
Priority 24686 is 24576 plus the VLAN ID 110, the extended system ID at work.
Access-switch practice
| Practice | Reason |
|---|---|
| Root and secondary root on the distribution switches | Predictable forwarding paths |
| PortFast and BPDU Guard on host ports | Fast host connectivity; err-disable if a switch is plugged in |
| Never disable STP | The guide warns loops can then cause severe traffic duplication |
Documented example, not captured output.
Platform, version and operating-envelope scope
Cisco IOS / IOS XE first; PVST+/Rapid-PVST+/MST behavior and defaults depend on configured mode.
Mechanics
Follow the path in order: physical link → switchport/bundle membership → VLAN/instance state → STP/LAG decision → MAC forwarding → end-to-end frame path.
ReferenceConfiguration & state1 section · depth on demand
Known-good / broken configuration and state reference
Broken: link-up can coexist with wrong VLAN, blocked STP state, native/allowed mismatch or stale/incorrect MAC forwarding.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Network Devices → Layer 2 Switch → STP. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.cisco.com/c/en/us/support/ios-nx-os-software/ios-xe-17/series.html · confidence 94%