spanning-tree bpduguard enable
Enables BPDU guard on an interface to protect against unauthorized switches by disabling the port if a BPDU is received, typically used on access ports to prevent bridge loops from rogue devices.
Definition: spanning-tree bpduguard enable is a Cisco IOS interface config command. Enables BPDU guard on an interface to protect against unauthorized switches by disabling the port if a BPDU is received, typically used on access ports to prevent bridge loops from rogue devices.
Overview
The `spanning-tree bpduguard enable` command is a critical tool in the Cisco IOS interface configuration mode used to protect the Layer 2 network from unauthorized switches or potential bridging loops. When enabled on a port, BPDU guard immediately places the interface into an errdisable state if a Bridge Protocol Data Unit (BPDU) is received. This is essential because BPDUs are exchanged by switches running Spanning Tree Protocol (STP) to elect a root bridge and prevent loops. On an access port that should only connect to end hosts (like PCs or printers), receiving a BPDU indicates that a rogue switch or a misconfigured device has been attached, which could disrupt the STP topology and cause network instability. By shutting down the port, BPDU guard acts as a safety mechanism, isolating the threat and alerting the network administrator.
BPDU guard is typically used in conjunction with PortFast, which is enabled on access ports to bypass the listening and learning states and transition directly to forwarding. While PortFast speeds up convergence for end hosts, it also makes the port vulnerable to STP attacks because the port does not expect BPDUs. BPDU guard complements PortFast by providing a security layer: if a BPDU arrives, the port is disabled, preventing the rogue device from participating in STP. This is a common best practice for campus networks where access ports are dedicated to end users.
When deciding between BPDU guard and other STP protection mechanisms like Root Guard or Loop Guard, consider the specific threat. BPDU guard is designed to protect against unauthorized switches that might try to become the root bridge or cause loops by sending BPDUs. Root Guard prevents a port from becoming a root port, even if it receives superior BPDUs, but it does not shut down the port. Loop Guard prevents alternate or backup ports from transitioning to forwarding if BPDUs stop arriving, which can happen due to unidirectional links. BPDU guard is the most aggressive: it immediately errdisables the port upon BPDU reception, making it ideal for access ports where no BPDUs should ever appear.
In the broader configuration workflow, BPDU guard is often applied globally using `spanning-tree portfast bpduguard default` under global configuration, which enables it on all PortFast-enabled ports. Alternatively, it can be applied per interface with `spanning-tree bpduguard enable`. The global approach is efficient for consistent policy, while per-interface gives granular control. After enabling BPDU guard, the running configuration shows the command under the interface. If a port is errdisabled due to BPDU guard, the administrator must manually re-enable it (after removing the offending device) using `shutdown` followed by `no shutdown` or configure errdisable recovery. The command requires privileged EXEC mode (enable) and interface configuration mode. It does not produce immediate output; verification is done via `show spanning-tree interface <interface> detail` or `show interfaces status err-disabled`.
spanning-tree bpduguard enableWhen to Use This Command
- Securing access ports on a switch to prevent a rogue switch from being connected and causing a bridging loop.
- Enforcing port security in a campus network where only end devices (PCs, printers) should be connected.
- Protecting the root bridge from being usurped by an unauthorized switch sending superior BPDUs.
- Automatically error-disabling a port when a BPDU is received, reducing manual intervention for loop prevention.
Command Examples
Enable BPDU Guard on an Access Port
interface GigabitEthernet0/1
switchport mode access
spanning-tree bpduguard enableSwitch(config-if)# spanning-tree bpduguard enable Switch(config-if)# end Switch# show spanning-tree interface GigabitEthernet0/1 detail Port 1 (GigabitEthernet0/1) of VLAN 1 is forwarding Port path cost 4, Port priority 128, Port Identifier 128.1. Designated root has priority 32768, address aabb.cc00.0100 Designated bridge has priority 32768, address aabb.cc00.0100 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 BPDU: sent 3, received 0 BPDU guard: enabled
The command enables BPDU guard on the interface. The output shows the interface is forwarding, BPDU guard is enabled, and no BPDUs have been received. If a BPDU were received, the port would transition to errdisable state.
Verify BPDU Guard Status and Errdisable Recovery
show interfaces status err-disabledPort Name Status Reason Gi0/1 Access Port err-disabled bpduguard Gi0/2 Trunk Port err-disabled bpduguard
This output shows ports that are in errdisable state due to BPDU guard. The 'Reason' column indicates 'bpduguard' as the cause. To recover, the port must be manually re-enabled or configured with errdisable recovery.
Understanding the Output
The 'show spanning-tree interface <interface> detail' command displays BPDU guard status under the interface details. The 'BPDU guard: enabled' line confirms the feature is active. If a BPDU is received, the port enters errdisable state, which can be seen with 'show interfaces status err-disabled' where the reason is 'bpduguard'.
Key fields: 'BPDU: sent 3, received 0' indicates no BPDUs received; if received count increases, the port will error-disable. In production, watch for errdisable ports to identify rogue devices or misconfigurations.
Configuration Scenarios
Enable BPDU Guard on an Access Port Connected to a Workstation
A network administrator wants to secure an access port (GigabitEthernet0/1) that connects to a user's PC. The port is configured with PortFast to speed up connectivity. To prevent any rogue switch from being plugged in and causing STP issues, BPDU guard is enabled.
Topology
SW1(Gi0/1)---PCSteps
- 1.Step 1: Enter global configuration mode: configure terminal
- 2.Step 2: Enter interface configuration mode for the access port: interface GigabitEthernet0/1
- 3.Step 3: Enable PortFast (if not already enabled): spanning-tree portfast
- 4.Step 4: Enable BPDU guard: spanning-tree bpduguard enable
- 5.Step 5: Exit configuration mode and save: end, write memory
! interface GigabitEthernet0/1 switchport mode access spanning-tree portfast spanning-tree bpduguard enable !
Verify: Use 'show spanning-tree interface GigabitEthernet0/1 detail' and look for 'Bpdu guard is enabled' in the output. Also check 'show interfaces status err-disabled' to see if any ports are in errdisable state due to BPDU guard.
Watch out: A common mistake is enabling BPDU guard on a trunk port. BPDU guard is intended for access ports; on trunk ports, BPDUs are expected, so enabling BPDU guard would cause the trunk to go errdisable upon receiving legitimate BPDUs.
Configure BPDU Guard Globally on All PortFast-Enabled Ports
An administrator wants to apply BPDU guard as a default policy on all access ports that have PortFast enabled. This ensures that any new access port configured with PortFast automatically gets BPDU guard without per-interface configuration.
Topology
SW1(Gi0/1-24)---Multiple PCsSteps
- 1.Step 1: Enter global configuration mode: configure terminal
- 2.Step 2: Enable PortFast globally on all access ports: spanning-tree portfast default
- 3.Step 3: Enable BPDU guard globally on all PortFast-enabled ports: spanning-tree portfast bpduguard default
- 4.Step 4: Exit and save: end, write memory
! spanning-tree portfast default spanning-tree portfast bpduguard default !
Verify: Use 'show running-config | include bpduguard' to see the global command. To verify on a specific interface, use 'show spanning-tree interface GigabitEthernet0/1 detail' and look for 'Bpdu guard is enabled' (even if not explicitly configured on the interface).
Watch out: If a port is configured with 'spanning-tree bpduguard disable' explicitly, it overrides the global default. Also, the global command only affects ports that have PortFast enabled (either via global default or per-interface). Ensure PortFast is enabled on the desired ports.
Troubleshooting with This Command
When troubleshooting BPDU guard, the primary symptom is a port that unexpectedly goes into errdisable state. The first step is to identify which ports are errdisabled using 'show interfaces status err-disabled'. This command lists all interfaces in errdisable state along with the reason, such as 'bpduguard'. If a port shows 'bpduguard' as the cause, it means a BPDU was received on that port. Next, examine the port configuration with 'show running-config interface <interface>' to confirm that BPDU guard is enabled. Also check if PortFast is enabled, as BPDU guard is typically used with PortFast. Use 'show spanning-tree interface <interface> detail' to see the BPDU guard status and the number of BPDUs received. The output includes 'Bpdu guard is enabled' and 'Bpdu guard errdisable count' which increments each time the port is errdisabled due to BPDU guard.
To recover the port, first remove the offending device (likely a switch or a device that sends BPDUs). Then, manually re-enable the port by entering interface configuration mode and issuing 'shutdown' followed by 'no shutdown'. Alternatively, configure errdisable recovery to automatically re-enable ports after a timeout: 'errdisable recovery cause bpduguard' and 'errdisable recovery interval <seconds>'. This is useful for temporary issues but should be used cautiously as it may allow a recurring problem to go unnoticed.
Correlating with other commands: 'show logging' may show messages like '%PM-4-ERR_DISABLE: bpduguard error detected on Gi0/1, putting Gi0/1 in err-disable state'. This log message confirms the event. Also, 'debug spanning-tree bpdu' can be used to monitor BPDU reception, but it is CPU-intensive and should be used sparingly. In a healthy network, access ports with BPDU guard should never receive BPDUs. If they do, investigate the connected device: it could be an unauthorized switch, a misconfigured device (e.g., a PC running a bridge), or a cable connected to another switch port. Use CDP or LLDP to discover neighboring devices if possible. If the port is a trunk port, BPDU guard should not be enabled; instead, consider Root Guard or Loop Guard for trunk ports.
CCNA Exam Tips
BPDU guard is configured per interface, not globally, unless using 'spanning-tree portfast bpduguard default'.
BPDU guard is typically used with PortFast on access ports; a BPDU received on a PortFast port triggers errdisable.
The exam may test that BPDU guard disables the port upon receiving any BPDU, not just superior ones.
Remember that BPDU guard is a Layer 2 security feature; it does not prevent BPDU transmission, only reception.
Common Mistakes
Enabling BPDU guard on trunk ports, which can cause legitimate BPDUs to disable the port.
Forgetting to configure errdisable recovery, requiring manual intervention to bring the port back up.
Confusing BPDU guard with BPDU filter; BPDU filter prevents sending/receiving BPDUs, while guard only disables on receipt.
spanning-tree bpduguard enable vs spanning-tree portfast
spanning-tree bpduguard enable and spanning-tree portfast are often paired on access ports to both accelerate host connectivity and protect against unauthorized switches. They are commonly confused because they are both configured in interface configuration mode and are frequently applied together for edge ports.
| Aspect | spanning-tree bpduguard enable | spanning-tree portfast |
|---|---|---|
| Scope | Per-interface (access or trunk) | Per-interface (typically access) |
| Configuration Mode | Interface Configuration (global also possible) | Interface Configuration |
| Persistence | Persistent across reloads | Persistent across reloads |
| Precedence | Port disabled if BPDU received | Port transitions directly to forwarding |
| Typical Use | Prevent bridge loops from rogue switches | Eliminate STP delay for end hosts |
Use spanning-tree bpduguard enable on all access ports to disable the port if an unauthorized BPDU is received, preventing potential loops.
Use spanning-tree portfast on ports connected to end hosts to bypass STP listening and learning states, enabling immediate forwarding.
Platform Notes
In IOS-XE (e.g., Catalyst 9000 series), the syntax and behavior of `spanning-tree bpduguard enable` are identical to classic IOS. The command is available in interface configuration mode and works the same way. However, IOS-XE may have additional features like errdisable recovery with more granular control.
For NX-OS (e.g., Nexus switches), the equivalent command is `spanning-tree bpduguard enable` under interface configuration mode, but NX-OS also supports `spanning-tree port type edge bpduguard default` globally. Note that NX-OS uses the term 'edge port' instead of PortFast. On ASA firewalls, BPDU guard is not directly applicable because ASA does not run STP in the same way; however, ASA can be configured to drop BPDUs on certain interfaces using access-lists or EtherType ACLs, but that is not a direct equivalent.
In IOS-XR, the command is not available; instead, STP protection is handled differently, often using features like BPDU guard on bridge domains or using the `spanning-tree bpduguard` command in the L2VPN context, but it is not a direct interface-level command. For IOS versions, the command has been available since at least IOS 12.x and remains consistent through 15.x and 16.x. One minor difference: in older IOS (12.x), the global command `spanning-tree portfast bpduguard default` might not exist; it was introduced in later versions.
Always check the specific IOS version documentation.
Related Commands
errdisable recovery cause psecure-violation
Enables automatic recovery of ports that have been error-disabled due to port security violation (psecure-violation), allowing them to come back up after a specified timeout without manual intervention.
show interfaces status
Displays a summary of all switch interfaces including their status, VLAN, duplex, speed, and type, used to quickly verify interface connectivity and configuration.
spanning-tree portfast
Bypasses the STP Listening and Learning states on a port, moving it directly to Forwarding after the link comes up. Eliminates the default 30-second STP convergence delay for ports connected to end hosts.
Practice for the CCNA 200-301
Test your knowledge with practice questions covering all CCNA 200-301 exam domains.
Practice CCNA 200-301 Questions