Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Networking hands-on

Lab · Medium · 50 minutesFree account

Spanning Tree Protocol (STP)

STP operation, root bridge election, and port states.

  • spanning-tree
  • rstp
  • switching
  • cisco-ios
  • ccna
On this page 7 sections
  1. 1Why STP Exists
  2. 2Root Bridge Election
  3. Locked: Port Roles
  4. Locked: Port States (802.1D STP)
  5. Locked: Configure Root Bridge
  6. Locked: RSTP (802.1w)
  7. Locked: STP Security Features

Before you start

Switches with redundant links form Layer 2 loops that flood a network with broadcasts in seconds. Spanning Tree Protocol stops the storm: it elects one root bridge and blocks the extra paths until a link fails. Security engineers must know how STP picks that root, because an unprotected access port lets an attacker become root and reroute every VLAN. In this lab, you then build the fix on Cisco switches.

Lab Objectives

  • Understand why Layer 2 loops are catastrophic
  • Explain how STP elects a root bridge using BID
  • Identify root, designated, and non-designated port roles
  • Configure the root bridge manually for predictable topology
  • Compare STP (802.1D) with RSTP (802.1w) convergence

Step 1: Why STP Exists

# Without STP, redundant switch links cause broadcast storms
SW1 ─── SW2
 │         │
 └─── SW3 ─┘

PC sends a broadcast:
→ SW1 floods to SW2 and SW3
→ SW2 floods it back to SW3
→ SW3 floods back to SW1 and SW2
→ LOOP: infinite broadcast storm → network crash!

# STP fixes this by:
# 1. Electing a ROOT BRIDGE (central switch)
# 2. Finding the BEST PATH to root from every switch
# 3. BLOCKING redundant paths (ports in blocking state)

# STP versions:
802.1D  → Original STP (30-50 second convergence — very slow)
802.1w  → RSTP - Rapid STP (1-2 second convergence — modern standard)
802.1s  → MSTP - Multiple STP (different trees per VLAN group)
PVST+   → Cisco's STP per VLAN (runs separate STP instance per VLAN)

Step 2: Root Bridge Election

# Root Bridge = switch with LOWEST Bridge ID (BID)
# BID = Priority (4 bits) + VLAN ID (12 bits) + MAC Address (48 bits)

# Default priority: 32768 (+ VLAN ID)
SW1: Priority 32769 (32768 + VLAN1), MAC: AA:AA:AA:AA:AA:01
SW2: Priority 32769 (32768 + VLAN1), MAC: BB:BB:BB:BB:BB:02
SW3: Priority 32769 (32768 + VLAN1), MAC: CC:CC:CC:CC:CC:03

# All same priority → lowest MAC wins root bridge
# SW1 wins (AA < BB < CC)

# Switches send BPDUs (Bridge Protocol Data Units) every 2 seconds
# to exchange BID information and agree on root bridge

# Show which switch is root bridge:
show spanning-tree vlan 1
Root ID    Priority    32769
           Address     aabb.cc01.0000
           This bridge is the root    ← You are root!

Bridge ID  Priority    32769
           Address     aabb.cc01.0000

Sign in to continue

5 more sections are for signed-in members. It is free: sign in with Google.

Related

This lab is extra practice for the course Networking hands-on. Do the lessons first.Open the course