PortFast & BPDU Guard Configuration
When an end device such as a PC, printer, or IP phone is plugged into a switch access port, it must wait up to 50 seconds for Spanning Tree Protocol (STP) to complete its Listening and Learning phases before the port starts forwarding traffic. For end devices that never participate in STP, this delay is unnecessary and causes problems — DHCP timeouts, slow boot issues, and user complaints about the network being unavailable after plugging in.
PortFast solves this by allowing access ports to skip straight to the Forwarding state. BPDU Guard works alongside PortFast to protect the network — if a BPDU is ever received on a PortFast-enabled port (which only happens if a switch is connected), the port is immediately shut down to prevent a rogue switch from disrupting the STP topology.
Before starting, complete Spanning Tree Protocol — Root Bridge Election and Assigning VLANs to Switch Ports.
1. The Problem PortFast Solves
Standard STP port states transition through four phases before forwarding traffic. For a switch port connecting two switches, every second of this process matters — it is preventing a loop. But for a PC plugged into an access port, there is no loop risk and no STP participation. The wait is completely wasted time:
| STP State | Duration | Activity | Problem for End Devices |
|---|---|---|---|
| Blocking | Up to 20 sec | Receives BPDUs only | PC gets no network — DHCP request sent but no response possible |
| Listening | 15 sec | Participating in STP election | PC still waiting — DHCP client may time out |
| Learning | 15 sec | Building MAC table, no forwarding | PC still cannot send or receive data |
| Forwarding | Indefinite | Normal operation | PC finally has network access — up to 50 seconds after plugging in |
PortFast makes the port skip Blocking, Listening, and Learning entirely — it goes directly to Forwarding the instant a device is connected. This is safe only on ports that connect to end devices, never to other switches.
PortFast vs Normal STP
| Feature | Normal STP Port | PortFast Port |
|---|---|---|
| Time to forwarding | Up to 50 seconds | ~1 second (immediate) |
| Transitions through | Blocking → Listening → Learning → Forwarding | Directly to Forwarding |
| Sends TCN on link up | ✅ Yes — triggers topology change notification | ❌ No — suppresses unnecessary TCNs |
| Safe for | Any port type | End devices only (PC, printer, IP phone, server) |
| Risk if used on trunk/switch port | N/A | ⚠️ Loop risk — must be protected by BPDU Guard |
2. BPDU Guard — The Safety Net
BPDUs (Bridge Protocol Data Units) are the control frames that switches send to each other to run STP. An end device (PC, printer, phone) never sends BPDUs — only switches do. This makes BPDUs a reliable indicator that something unexpected is connected to a PortFast port.
BPDU Guard monitors PortFast-enabled ports for incoming BPDUs. The moment a BPDU is received on such a port, BPDU Guard immediately places the port into err-disabled state — a hardware-level shutdown that completely stops the port from forwarding any traffic. A log message is generated and the port stays down until an administrator manually recovers it (or automatic recovery is configured).
BPDU Guard Trigger Scenarios
| What Was Connected | BPDU Sent? | BPDU Guard Action | Result |
|---|---|---|---|
| PC, laptop, printer | ❌ No | None — port stays up | ✅ Normal operation |
| Rogue unmanaged switch | ✅ Yes | Port immediately err-disabled | 🛑 Port shutdown — loop prevented |
| Managed switch (STP running) | ✅ Yes | Port immediately err-disabled | 🛑 Port shutdown — rogue switch isolated |
| IP phone (CDP only, no STP) | ❌ No | None — port stays up | ✅ Normal operation |
shutdown command). The interface shows
"err-disabled" in show interfaces and
"down/err-disabled" in
show ip interface brief.
It requires manual recovery or automatic err-disabled recovery.
3. Lab Scenario
NetsTuts_SW1 has three types of ports to configure:
| Port | Connected To | VLAN | PortFast | BPDU Guard |
|---|---|---|---|---|
| Fa0/1 – Fa0/10 | End-user PCs | 10 | ✅ Yes | ✅ Yes |
| Fa0/11 – Fa0/20 | IP Phones + PCs | 20 (data) + Voice | ✅ Yes | ✅ Yes |
| Gi0/1 | NetsTuts_SW2 (uplink) | Trunk | ❌ No | ❌ No |
4. Step 1 — Enable PortFast Per Interface
The most common and recommended approach is to enable PortFast explicitly on each access port. This gives precise control over which ports have PortFast enabled.
NetsTuts_SW1>en NetsTuts_SW1#conf t Enter configuration commands, one per line. End with CNTL/Z. ! ── PortFast on a single access port ───────────────────── NetsTuts_SW1(config)#interface FastEthernet0/1 NetsTuts_SW1(config-if)#description PC-VLAN10-User1 NetsTuts_SW1(config-if)#switchport mode access NetsTuts_SW1(config-if)#switchport access vlan 10 NetsTuts_SW1(config-if)#spanning-tree portfast NetsTuts_SW1(config-if)#spanning-tree bpduguard enable NetsTuts_SW1(config-if)#exit
IOS Warning When Enabling PortFast
NetsTuts_SW1(config-if)#spanning-tree portfast %Warning: portfast should only be enabled on ports connected to a single host. Connecting hubs, concentrators, switches, bridges, etc... to this interface when portfast is enabled, can cause temporary bridging loops. Use with CAUTION %Portfast has been configured on FastEthernet0/1 but will only have effect when the interface is in a non-trunking mode.
Enable PortFast on a Range of Access Ports
NetsTuts_SW1(config)#interface range FastEthernet0/1 - 10 NetsTuts_SW1(config-if-range)#description PC-VLAN10 NetsTuts_SW1(config-if-range)#switchport mode access NetsTuts_SW1(config-if-range)#switchport access vlan 10 NetsTuts_SW1(config-if-range)#spanning-tree portfast NetsTuts_SW1(config-if-range)#spanning-tree bpduguard enable NetsTuts_SW1(config-if-range)#exit
interface range. Efficient for bulk access port configuration.
5. Step 2 — Global PortFast and BPDU Guard (Optional)
Cisco IOS also supports enabling PortFast and BPDU Guard globally — applying them automatically to all access ports on the switch. This is convenient but requires careful management to ensure trunk ports are never accidentally left in access mode.
Enable PortFast Globally (Access Ports Only)
NetsTuts_SW1(config)#spanning-tree portfast default
Enable BPDU Guard Globally
NetsTuts_SW1(config)#spanning-tree portfast bpduguard default
spanning-tree portfast default —
every access port automatically gets both PortFast and BPDU Guard.
Global vs Per-Interface — Comparison
| Method | Command | Scope | Best For |
|---|---|---|---|
| Per-interface PortFast | spanning-tree portfast |
Single interface or range | Precise control — production recommended |
| Per-interface BPDU Guard | spanning-tree bpduguard enable |
Single interface or range | Precise control — always pair with PortFast |
| Global PortFast | spanning-tree portfast default |
All access-mode ports | Bulk configuration — all access ports in one command |
| Global BPDU Guard | spanning-tree portfast bpduguard default |
All PortFast-enabled ports | Automatic security — pairs with global PortFast |
no spanning-tree portfast command on the individual
interface. This is important for any port that might occasionally be used as a
trunk or connected to another switch.
6. Complete Configuration
! ══════════════════════════════════════════════════════════ ! NetsTuts PortFast & BPDU Guard Baseline — NetsTuts_SW1 ! ══════════════════════════════════════════════════════════ NetsTuts_SW1>en NetsTuts_SW1#conf t Enter configuration commands, one per line. End with CNTL/Z. ! ── Global PortFast and BPDU Guard (all access ports) ──── NetsTuts_SW1(config)#spanning-tree portfast default NetsTuts_SW1(config)#spanning-tree portfast bpduguard default ! ── Access ports — VLAN 10 user PCs ───────────────────── NetsTuts_SW1(config)#interface range FastEthernet0/1 - 10 NetsTuts_SW1(config-if-range)#description PC-VLAN10 NetsTuts_SW1(config-if-range)#switchport mode access NetsTuts_SW1(config-if-range)#switchport access vlan 10 NetsTuts_SW1(config-if-range)#exit ! ── Access ports — VLAN 20 + Voice ─────────────────────── NetsTuts_SW1(config)#interface range FastEthernet0/11 - 20 NetsTuts_SW1(config-if-range)#description IPPhone-VLAN20 NetsTuts_SW1(config-if-range)#switchport mode access NetsTuts_SW1(config-if-range)#switchport access vlan 20 NetsTuts_SW1(config-if-range)#switchport voice vlan 100 NetsTuts_SW1(config-if-range)#exit ! ── Uplink trunk — NO PortFast ─────────────────────────── NetsTuts_SW1(config)#interface GigabitEthernet0/1 NetsTuts_SW1(config-if)#description Trunk-to-NetsTuts_SW2 NetsTuts_SW1(config-if)#switchport trunk encapsulation dot1q NetsTuts_SW1(config-if)#switchport mode trunk NetsTuts_SW1(config-if)#switchport nonegotiate NetsTuts_SW1(config-if)#spanning-tree portfast disable NetsTuts_SW1(config-if)#end NetsTuts_SW1#wr Building configuration... [OK] NetsTuts_SW1#
7. Recovering from err-disabled State
When BPDU Guard triggers on a port, the port is placed into err-disabled state and a syslog message is generated:
%SPANTREE-2-BLOCK_BPDUGUARD: Received BPDU on port FastEthernet0/5 with BPDU Guard enabled. Disabling port. %PM-4-ERR_DISABLE: bpduguard error detected on Fa0/5, putting Fa0/5 in err-disable state %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to down %LINK-3-UPDOWN: Interface FastEthernet0/5, changed state to down
show logging to see these messages and
Syslog Configuration to forward them to a central server.
Verify err-disabled State
NetsTuts_SW1#show interfaces FastEthernet0/5 status Port Name Status Vlan Duplex Speed Type Fa0/5 err-disabled 10 auto auto 10/100BaseTX
NetsTuts_SW1#show interfaces FastEthernet0/5 FastEthernet0/5 is down, line protocol is down (err-disabled) Hardware is Fast Ethernet, address is 0012.3456.0005 ...
NetsTuts_SW1#show errdisable recovery ErrDisable Reason Timer Status Timer Interval -------------------------- -------------- -------------- bpduguard Disabled 300
show errdisable recovery shows that automatic recovery for
bpduguard is disabled by default — manual recovery is required.
Method 1: Manual Recovery (Recommended)
NetsTuts_SW1#conf t ! ── 1. Remove the rogue switch first ───────────────────── ! ── 2. Shut the port, then bring it back ───────────────── NetsTuts_SW1(config)#interface FastEthernet0/5 NetsTuts_SW1(config-if)#shutdown NetsTuts_SW1(config-if)#no shutdown NetsTuts_SW1(config-if)#end NetsTuts_SW1# %LINK-3-UPDOWN: Interface FastEthernet0/5, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to up
no shutdown, BPDU Guard will trigger
again immediately and the port will be err-disabled again within seconds.
Method 2: Automatic err-disabled Recovery
NetsTuts_SW1(config)#errdisable recovery cause bpduguard NetsTuts_SW1(config)#errdisable recovery interval 300
8. Verification
show spanning-tree interface FastEthernet0/1 portfast
NetsTuts_SW1#show spanning-tree interface FastEthernet0/1 portfast VLAN0010 enabled
show spanning-tree interface FastEthernet0/1 detail
NetsTuts_SW1#show spanning-tree interface FastEthernet0/1 detail Port 1 (FastEthernet0/1) of VLAN0010 is designated forwarding Port path cost 19, Port priority 128, Port Identifier 128.1. Designated root has priority 4097, address 0001.0001.0001 Designated bridge has priority 4097, address 0001.0001.0001 Designated port id is 128.1, designated path cost 0 Timers: message age 0, forward delay 0, hold 0 Number of transitions to forwarding state: 1 The port is in the portfast mode Link type is point-to-point by default
show spanning-tree summary
NetsTuts_SW1#show spanning-tree summary Switch is in rapid-pvst mode Root bridge for: VLAN0010 VLAN0020 Extended system ID is enabled Portfast Default is enabled PortFast BPDU Guard Default is enabled Portfast BPDU Filter Default is disabled Loopguard Default is disabled Name Blocking Listening Learning Forwarding STP Active ---------------------- -------- --------- -------- ---------- ---------- VLAN0010 0 0 0 10 10 VLAN0020 0 0 0 10 10
show running-config interface FastEthernet0/1
NetsTuts_SW1#show running-config interface FastEthernet0/1 ! interface FastEthernet0/1 description PC-VLAN10-User1 switchport access vlan 10 switchport mode access spanning-tree portfast spanning-tree bpduguard enable !
Verification Command Summary
| Command | What It Confirms |
|---|---|
show spanning-tree interface [int] portfast |
PortFast status on a specific interface per VLAN |
show spanning-tree interface [int] detail |
Detailed STP info including "The port is in the portfast mode" |
show spanning-tree summary |
Global PortFast and BPDU Guard status, port counts per VLAN |
show interfaces [int] status |
Shows "err-disabled" if BPDU Guard has triggered on the port |
show errdisable recovery |
Shows err-disabled causes and whether auto-recovery is configured |
show logging |
BPDU Guard trigger events and err-disabled log messages |
9. Troubleshooting PortFast & BPDU Guard Issues
| Problem | Symptom | Cause | Fix |
|---|---|---|---|
| Port immediately err-disabled after recovery | Port comes up then drops again within seconds | Rogue switch is still connected — BPDU Guard triggers again immediately | Disconnect the switch first, then recover the port with shutdown / no shutdown |
| DHCP timeout on PC boot | PC takes 30–60 seconds to get an IP after connecting | PortFast not enabled — port goes through full STP convergence | Enable spanning-tree portfast on the access port |
| PortFast not working on a port | Port still waits ~30 seconds before forwarding | Port is configured as trunk — PortFast only operates in non-trunking mode | Ensure switchport mode access is set before spanning-tree portfast |
| Loop risk — PortFast on wrong port | PortFast enabled on a trunk or inter-switch link | PortFast enabled on a non-access port — loop could form before STP acts | Remove PortFast: no spanning-tree portfast. Ensure BPDU Guard is enabled to protect |
| BPDU Guard not triggering | Rogue switch connected but port stays up | BPDU Guard not configured on the port (PortFast enabled but BPDU Guard missing) | Add spanning-tree bpduguard enable on the interface, or enable globally with spanning-tree portfast bpduguard default |
| Port shows err-disabled but no rogue switch | Legitimate device caused BPDU Guard to trigger | Device (e.g., an IP phone with an embedded switch) is sending BPDUs | Verify the device — if it is a known managed device, reconsider port security policy. Recover with shutdown / no shutdown |
Key Points & Exam Tips
- PortFast allows an access port to skip STP Listening and Learning states and go directly to Forwarding — reducing the wait from up to 50 seconds to approximately 1 second.
- PortFast is only safe on ports connected to end devices (PCs, printers, IP phones, servers). Never enable it on trunk ports or inter-switch links.
- PortFast also suppresses Topology Change Notifications (TCNs) when the port comes up — preventing unnecessary MAC table flushes across the network.
- BPDU Guard places a PortFast-enabled port into err-disabled state the instant a BPDU is received — protecting against rogue switch connections.
- An err-disabled port is completely shut down at hardware level. Recovery requires
shutdownfollowed byno shutdown— after removing the offending device. - Per-interface:
spanning-tree portfastandspanning-tree bpduguard enable. Global:spanning-tree portfast defaultandspanning-tree portfast bpduguard default. spanning-tree portfast defaultonly applies to ports in access mode — trunk ports are automatically excluded.show spanning-tree summaryshows whether global PortFast and BPDU Guard are enabled. Look for "Portfast Default is enabled" and "PortFast BPDU Guard Default is enabled".- Automatic err-disabled recovery (
errdisable recovery cause bpduguard) is available but use with caution — if the rogue switch is still connected, the port will keep cycling between up and err-disabled. - On the CCNA exam, know the difference between BPDU Guard (err-disables the port) and BPDU Filter (suppresses BPDUs on PortFast ports — less commonly tested but important to distinguish). Also review RSTP which converges much faster than classic STP and works alongside PortFast.