Why PortFast needs a partner
PortFast declares that an interface is an edge port: it is expected to connect to an endpoint without another Layer 2 path back into the network. But someone might plug a switch into it, or connect a cable back into another port. A PortFast port forwards at once, so a loop can form before STP reacts. A BPDU (Bridge Protocol Data Unit) is an STP control message normally exchanged by bridges. BPDU Guard enforces a policy that this endpoint port must not receive those messages. On a guarded port, a received BPDU triggers protective action; it does not need to advertise a better root.
Our access switch is SW3. Gi1/0/10 connects to an ordinary lab PC in VLAN 10; Gi1/0/11 is another endpoint port where someone attaches a desk switch. A permitted PC might use 192.168.10.20/24, but its IP address does not trigger the guard. The trigger is the received Layer 2 control frame.
The usual response shown here is err-disabled: the switch stops normal interface operation because it detected a protection violation. That differs from a healthy STP alternate port, which can stay physically up and receive BPDUs while discarding user frames. Platform features can support VLAN-specific action; verify the actual errdisable scope on your release.
Device key: PC (computer)
Lines show the example’s network connections. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type. Blocked: forwarding prevented by a port or policy. Down: failed link. Read the step for the cause.
- 1. End devices are fine. PCs don't normally send BPDUs, so BPDU Guard leaves them alone.
- 2. A switch is plugged in. The desk switch sends BPDUs into Gi1/0/11.
- 3. Port err-disabled. SW3 stops Gi1/0/11 after receiving the BPDU. This enforces the edge policy; it is not proof that every possible loop was prevented before any frame circulated.
An unexpected bridge can affect root selection or cause topology-change processing without first becoming root. That processing can increase flooding by ageing or flushing learned MAC entries, depending on the protocol. Guard rejects the received BPDU according to the port policy; it does not classify the sender as malicious or prove that all network risks are removed.
The border of your STP domain
Think of PortFast + BPDU Guard ports as the border of your STP network. Inside the border, switches send each other BPDUs. At the border, no BPDU is allowed in.
| Port | PortFast | BPDU Guard | Root Guard |
|---|---|---|---|
| Access port to a PC, printer, phone | Yes | Yes | Not needed |
| Normal access-switch uplink | No | No: expected to receive BPDUs | Usually no where the intended root is upstream |
| Distribution port facing access | No | No: legitimate switches exchange BPDUs | Consider where the root must not appear downstream |
Root Guard is different: it prevents a port from accepting superior root information, placing it into a root-inconsistent condition until that information stops. BPDU Guard reacts to received BPDUs on a protected edge, whether superior or inferior, and its errdisable response normally requires manual or enabled timed recovery.
Per port or for the whole switch
These examples use Cisco IOS/IOS XE style commands beginning in global configuration mode. VLAN 10 already exists. Check the release syntax; some images use explicit portfast edge forms. Choose the local or inherited global policy deliberately rather than assuming they apply to identical interfaces.
interface GigabitEthernet1/0/11
switchport mode access
switchport access vlan 10
spanning-tree portfast
spanning-tree bpduguard enableSW3, one verified endpoint port. The explicit interface command spanning-tree bpduguard enable protects this port even without PortFast. Do not put that command on a normal uplink that must receive BPDUs.
spanning-tree portfast default
spanning-tree portfast bpduguard defaultAlternative global policy. The first command enables PortFast by default on non-trunks; the second supplies guard to interfaces in the operational PortFast state, subject to local overrides. Some images use spanning-tree portfast edge bpduguard default.
Explicit enable applies guard at the interface. Explicit disable, spanning-tree bpduguard disable, overrides the global default there. Removing an interface override with no spanning-tree bpduguard returns to inherited behaviour; with a global default and operational PortFast, that can still mean protected. An explicitly configured PortFast trunk can also inherit the global guard. An ordinary non-edge trunk does not.
The log when a switch appears
%SPANTREE-2-BLOCK_BPDUGUARD: Received BPDU on port Gi1/0/11 with BPDU Guard enabled. Disabling port. %PM-4-ERR_DISABLE: bpduguard error detected on Gi1/0/11, putting Gi1/0/11 in err-disable state
SW3#show interfaces status err-disabled Port Name Status Reason Err-disabled Vlans Gi1/0/11 err-disabled bpduguard
The reason bpduguard identifies the protection that fired; err-disabled alone does not. Compare the logs, interface configuration, global defaults and physical connection. PortFast status explains policy eligibility, while the reason explains why operation stopped.
Recovering the port
Inspect the endpoint, cabling and logs. A desk switch, software bridge, patching error or an intended network connection placed on the wrong kind of port can all require different repairs. Establish what the port should connect to before enabling it again.
For this endpoint example, remove the desk switch or other BPDU source and reconnect only the intended PC. Then reset the interface manually:
interface GigabitEthernet1/0/11
shutdown
no shutdownSW3 Gi1/0/11, starting in global configuration mode, after correcting the cause. Keep PortFast and guard as the intended endpoint policy. Recheck link state, logs and PC connectivity.
Consider timed recovery only as a separate policy
Timed recovery retries eligible ports without a manual reset. It does not inspect the cabling or repair the topology. The interval setting can affect other enabled errdisable recovery causes too; record the current policy before changing it.
errdisable recovery cause bpduguard
errdisable recovery interval 300Optional global policy, not required for the manual lab. Retry bpduguard-disabled interfaces at the configured interval; supported ranges depend on the image. If the cause remains and another BPDU arrives, guard can trigger again.
SW1#show errdisable recovery ErrDisable Reason Timer Status ----------------- -------------- bpduguard Enabled ... Timer interval: 300 seconds Interfaces that will be enabled at the next timeout: Interface Errdisable reason Time left(sec) --------- ----------------- -------------- Gi1/0/11 bpduguard 214
Note: show interfaces only says err-disabled. To see the reason, use show interfaces status err-disabled where supported, then correlate logs. Automatic recovery trades a shorter unattended outage for the possibility of repeatedly reintroducing an unsafe connection. It is not a substitute for someone correcting the cause.
A template for access switches
! access switch, global
spanning-tree portfast default
spanning-tree portfast bpduguard default
!
! any access port that really does lead to a switch
interface GigabitEthernet1/0/48
description Link to lab switch
spanning-tree portfast disable
spanning-tree bpduguard disableSeparate reviewed edge-default template. Gi1/0/48 is a legitimate non-edge switch link and is explicitly excluded. Normal trunks are not made PortFast by the global access default, but explicit PortFast trunk or explicit guard settings still need review.
Limits: BPDU Guard can't detect a hub or cheap switch on its own, and it misses a loop through a device that drops BPDUs. Storm control can limit selected traffic rates, but does not calculate or remove a loop. Keep a loop-free design and normal STP control traffic; BPDU Guard cannot detect a condition for which no triggering BPDU reaches it.
Short lab: trigger one guarded port without making a loop
Use an isolated SW3 with a console connection, VLAN 10 and unused Gi1/0/11. Record its original settings and verify that automatic bpduguard recovery is disabled for this manual exercise. Apply the one-port access/PortFast/guard block. Connect one test switch that sends unfiltered STP BPDUs by exactly one cable to Gi1/0/11, with no other test-switch uplink. You need a BPDU, not a physical loop.
show interfaces status err-disabled
show logging | include BPDUGUARD|ERR_DISABLE
show errdisable recoverySW3, privileged EXEC. Confirm Gi1/0/11 stopped specifically for bpduguard. The console keeps management available while the isolated test interface is disabled.
Remove the test switch, reconnect the intended PC and perform the shown shutdown/no shutdown reset. Verify forwarding, operational PortFast and PC connectivity without another guard event. Restore the recorded interface settings if the lab is temporary. Leave global automatic recovery unchanged; no additional switch link or loop is required.
Test yourself on BPDU Guard
How does BPDU Guard differ from Root Guard when triggered?
With 'spanning-tree portfast bpduguard default', which ports are protected?
Global PortFast BPDU Guard is enabled. You remove a local guard command with no spanning-tree bpduguard on an operational edge port. Is guard necessarily off?
Sources: Cisco PortFast and BPDU Guard; Cisco interface/global command inheritance; Cisco errdisable diagnosis and recovery. Output is illustrative, not captured from a tested switch image.