Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

STP (Spanning Tree Protocol) · Layer 2 Switch

Direct answer

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.

When to use this

Use it when checking loop prevention, root placement or edge-port protection on a switch.

First 30 seconds

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.

Operational verification

BPDUs → root → roles → loop-free

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Cisco IOS / IOS XE
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformCisco IOS / IOS XE · Cisco IOS XE
Scope / prerequisiteUse it when checking loop prevention, root placement or edge-port protection on a switch.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

3 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Command lookup Jump straight to Cisco syntax
Key points
  • STP prevents Layer 2 loops by blocking redundant paths.
  • Rapid PVST+ and MST are the common modern variants.
  • Set the root bridge deliberately.
Key checks
  • show spanning-tree summary — mode, root
  • show 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)

ElementDetail
Bridge ID4-bit priority + 12-bit extended system ID (VLAN) + MAC address
Default priority32768; lowest wins; ties go to the lowest MAC
root primarySets 24576 if that makes the switch root
root secondarySets 28672
Valid prioritiesMultiples of 4096 from 0 to 61440

Port roles (STP guide)

RoleMeaning
Root portBest path to the root on a non-root switch
Designated portForwarding port elected for each segment
Alternate portBlocked; alternate path to the root
Backup portBlocked; in a loopback configuration

Default path costs and timers (STP guide)

SpeedCost
1 Gbit/s20000
10 Gbit/s2000
40 Gbit/s500
100 Gbit/s200

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

PracticeReason
Root and secondary root on the distribution switchesPredictable forwarding paths
PortFast and BPDU Guard on host portsFast host connectivity; err-disable if a switch is plugged in
Never disable STPThe guide warns loops can then cause severe traffic duplication

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Platform, version and operating-envelope scope

Cisco IOS / IOS XE first; PVST+/Rapid-PVST+/MST behavior and defaults depend on configured mode.

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
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docCisco IOS / IOS XE Current documentation reviewed 2026-09-14

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%
Confirmation

Confirm action

Continue?