Domain 2Network AccessADVANCED

STP Tools and Features

Advanced STP features and tools for network optimization and security, including PortFast, BPDU Guard, Root Guard, and Loop Guard.

Domain: Domain 2: Network Access•Updated: 2026-08-26
#PortFast#BPDU Guard#Root Guard#Loop Guard#STP Optimization

Spanning Tree Protocol (STP) Toolkit

The STP Toolkit consists of optional features used to modify and enhance STP behavior, improve convergence times for end hosts, and protect the network topology from unauthorized changes or physical link failures.

PortFast

  • Concept: Allows a switch port connected to an end host to immediately enter the STP Forwarding state, bypassing the Listening and Learning states.
  • Details:
    • Default STP delay: 15 seconds (Listening) + 15 seconds (Learning) = 30 seconds.
    • Prevents the “internet doesn’t work” delay when a user connects a PC.
    • Rule: ONLY enable on ports connected to end hosts (PCs, routers, virtualization servers). NEVER enable on ports connected to other switches, as it bypasses loop-prevention checks and can cause temporary Layer 2 loops.
    • By default, PortFast only activates on access ports, not trunk ports.

PortFast Configuration

! Enable on a specific access interface
Switch(config-if)# spanning-tree portfast 
! Modern IOS automatically appends 'edge' -> spanning-tree portfast edge

! Enable on a specific trunk interface (Use case: Router-on-a-stick, Virtualization server)
Switch(config-if)# spanning-tree portfast trunk

! Enable by default on ALL access ports globally
Switch(config)# spanning-tree portfast default

! Disable PortFast on a specific interface (if enabled globally)
Switch(config-if)# spanning-tree portfast disable

PortFast Verification

Switch# show spanning-tree interface gigabitethernet 0/1 detail
! Look for: "The port is in the portfast edge mode"

Switch# show running-config interface gigabitethernet 0/1
! Note: Modern IOS adds the 'edge' keyword automatically. Packet Tracer may not support the 'edge' keyword.

Things to note: There are two types of PortFast: Edge (covered here, for end hosts) and Network (used for Bridge Assurance, not a CCNA topic).

BPDU Guard and BPDU Filter

These features manage how a port handles BPDUs (Bridge Protocol Data Units) and are typically used in combination with PortFast on end-host ports.

BPDU Guard

  • Concept: Protects the STP topology from unauthorized switches. If a BPDU Guard-enabled port receives a BPDU, it immediately enters the err-disabled state (shuts down the port).
  • Configuration:
! Enable per-port
Switch(config-if)# spanning-tree bpduguard enable

! Enable globally on ALL PortFast-enabled ports (Not necessarily all access ports)
Switch(config)# spanning-tree portfast bpduguard default

! Disable per-port
Switch(config-if)# spanning-tree bpduguard disable
  • Err-Disable Recovery:
    • When a port is err-disabled, it must be fixed.
    • Manual Recovery: shutdown followed by no shutdown on the interface.
    • Automatic Recovery: Disabled by default. Default timer is 300 seconds (5 minutes).
! View err-disable recovery status and timers
Switch# show errdisable recovery

! Enable automatic recovery for BPDU Guard violations
Switch(config)# errdisable recovery cause bpduguard

! Modify the recovery timer (e.g., to 60 seconds)
Switch(config)# errdisable recovery interval 60

Things to note: Always resolve the underlying issue (e.g., remove the unauthorized switch) before re-enabling the port, otherwise it will just be err-disabled again.

BPDU Filter

  • Concept: Prevents a port from sending BPDUs. Its behavior changes drastically depending on how it is configured!
  • Configuration & Behavior:
! 1. Enable per-port (HIGH RISK)
Switch(config-if)# spanning-tree bpdufilter enable
! Behavior: Port stops sending BPDUs AND ignores any received BPDUs. Effectively disables STP on the port. Can cause permanent Layer 2 loops if connected to a switch.

! 2. Enable globally (RECOMMENDED)
Switch(config)# spanning-tree portfast bpdufilter default
! Behavior: Port stops sending BPDUs. BUT if it receives a BPDU, PortFast and BPDU Filter are disabled, and it reverts to a normal STP port. 

! Disable per-port
Switch(config-if)# spanning-tree bpdufilter disable

Things to note: It is highly recommended to ONLY enable BPDU Filter globally. Enabling it per-port disables STP entirely on that interface, which is dangerous.

BPDU Guard vs. BPDU Filter Interaction

If both are enabled on the same port, the result depends on how BPDU Filter was configured:

BPDU Filter Config Port Receives BPDU Result
Global (Default) Yes BPDU Filter disables itself. BPDU Guard triggers -> Port goes to err-disabled.
Per-Port (Interface) Yes BPDU Filter ignores the BPDU. BPDU Guard does NOT trigger. Port stays up, STP is disabled.

Root Guard

  • Concept: Guards the root bridge of the LAN. Prevents a port from becoming a Root Port by blocking it if superior BPDUs (BPDUs claiming a better Root Bridge ID) are received.
  • Use Case: Connecting your network to switches outside your direct control (e.g., Service Provider connecting to a Customer). Ensures your designated switch remains the Root Bridge.
  • Configuration:
    • Can ONLY be configured per-port. There is no global default command.
Switch(config-if)# spanning-tree guard root
  • Behavior:
    • If a superior BPDU is received, the port enters the root-inconsistent state.
    • In show spanning-tree, the status shows as BKN (Broken).
    • The port is blocked (cannot forward frames) but remains physically up/up.
  • Recovery:
    • Automatic. Once the superior BPDUs stop (e.g., the customer changes their switch priority to be higher), the port automatically recovers after the Max Age timer (default 20 seconds) expires. No manual intervention or errdisable recovery is needed.

Things to note: Do not configure Root Guard on the customer side if you want to communicate with the provider, as it will block the link upon receiving the provider’s superior BPDUs.

Loop Guard

  • Concept: Protects against Layer 2 loops caused by unidirectional links or software bugs where a port unexpectedly stops receiving BPDUs.
  • Unidirectional Link: A physical link where traffic flows in only one direction (often caused by damaged fiber-optic cables where Tx/Rx fibers are separate, but the switch fails to detect the physical failure).
  • The Problem: If a blocking port (Root or Non-Designated) stops receiving BPDUs, it assumes the path to the root is gone. After the Max Age timer (20s), it transitions to a Designated Port and starts forwarding, creating a Layer 2 loop.
  • Loop Guard Solution: If BPDUs stop arriving, the port enters the loop-inconsistent state (status BKN in show spanning-tree), keeping the port blocked.
  • Configuration:
! Enable per-port (Typically on Root and Non-Designated ports)
Switch(config-if)# spanning-tree guard loop

! Enable globally on all ports
Switch(config)# spanning-tree loopguard default

! Disable per-port
Switch(config-if)# spanning-tree guard none
  • Recovery:
    • Automatic. Once BPDUs are received again (e.g., the fiber cable is fixed), the port automatically unblocks.

Root Guard vs. Loop Guard Comparison

These two features are mutually exclusive and cannot be enabled on the same port simultaneously. They serve opposite purposes.

Feature Protects Against Trigger Condition Port State When Blocked Target Port Types
Root Guard Unauthorized Root Bridge Receives Superior BPDUs Root-Inconsistent (BKN) Designated Ports (connecting to untrusted networks)
Loop Guard Unidirectional Links / Missing BPDUs Stops receiving BPDUs Loop-Inconsistent (BKN) Root & Non-Designated Ports (supposed to receive BPDUs)

Things to note: Because they are mutually exclusive, the more specific configuration takes precedence. If Loop Guard is enabled globally, but you configure spanning-tree guard root on a specific interface, Loop Guard is disabled on that interface.


STP Toolkit Command Summary

PortFast Commands

Switch(config-if)# spanning-tree portfast [edge]
Switch(config-if)# spanning-tree portfast trunk
Switch(config)# spanning-tree portfast default
Switch(config-if)# spanning-tree portfast disable

BPDU Guard Commands

Switch(config-if)# spanning-tree bpduguard enable
Switch(config)# spanning-tree portfast bpduguard default
Switch(config-if)# spanning-tree bpduguard disable
Switch(config)# errdisable recovery cause bpduguard
Switch(config)# errdisable recovery interval <seconds>

BPDU Filter Commands

Switch(config-if)# spanning-tree bpdufilter enable
Switch(config)# spanning-tree portfast bpdufilter default
Switch(config-if)# spanning-tree bpdufilter disable

Root Guard Commands

Switch(config-if)# spanning-tree guard root

Loop Guard Commands

Switch(config-if)# spanning-tree guard loop
Switch(config)# spanning-tree loopguard default
Switch(config-if)# spanning-tree guard none

Verification Commands

Switch# show spanning-tree interface <interface> detail
Switch# show running-config interface <interface>
Switch# show spanning-tree
Switch# show errdisable recovery
Switch# show interfaces <interface>