Sub topic 17
BPDU Guard, Root Guard and Loop Guard
This chapter assumes you know how root bridge election and port roles work, and that you have used the Cisco IOS command line. Spanning tree trusts every BPDU it receives. The three guard features limit that trust. Each one protects a different part of the topology.
Which guard protects what
| Feature | Where it goes | Trigger | Action |
|---|---|---|---|
| BPDU Guard | Edge (PortFast) ports | Any BPDU arrives | Port goes to err-disabled |
| Root Guard | Designated ports facing switches you do not want as root | Superior BPDU arrives | Port goes to root-inconsistent |
| Loop Guard | Root and alternate ports on point-to-point links | BPDUs stop arriving | Port goes to loop-inconsistent |
BPDU Guard
A host port should never receive a BPDU. If one arrives, someone has probably plugged in a switch or created a loop through a small desktop switch. BPDU Guard shuts the port down right away. You re-enable it by hand, or with errdisable recovery.
Root Guard
Root Guard stops a port from accepting a better root. Suppose a new switch with a low priority joins the network. Without Root Guard it could win the election and reshape the tree. With Root Guard, the port ignores that BPDU and moves to a root-inconsistent state. It recovers by itself once the superior BPDUs stop.
Use it on ports that face switches outside your control, or on distribution-to-access ports. Never use it on a port that legitimately leads toward the root.
Loop Guard
A blocked port keeps listening for BPDUs. If a unidirectional link fault stops those BPDUs, the port ages out its information and starts forwarding. That creates a loop. Loop Guard keeps the port in a loop-inconsistent (blocking) state instead. When BPDUs return, the port recovers.
Configuration
! Edge port facing an end host
interface GigabitEthernet0/5
switchport mode access
switchport access vlan 10
spanning-tree portfast
spanning-tree bpduguard enable
! Distribution-to-access port that must never lead to the root
interface GigabitEthernet0/24
spanning-tree guard root
! Loop Guard on all point-to-point links by default
configure terminal
spanning-tree loopguard default
end
! Optional: recover err-disabled ports automatically
configure terminal
errdisable recovery cause bpduguard
errdisable recovery interval 300
endChecking the result
show spanning-tree inconsistentports
show spanning-tree summary
show interfaces status err-disabledshow spanning-tree inconsistentports lists ports held by Root Guard or Loop Guard, along with the VLAN affected.
Common mistakes
- Enabling Root Guard on the port that leads to the real root. That port then goes inconsistent and the switch loses its path.
- Enabling Loop Guard and PortFast on the same port. They conflict, because an edge port is not meant to receive BPDUs.
- Leaving BPDU Guard off host ports and relying on users not to plug in switches.
Exercise
A port on an access switch is in the root-inconsistent state in VLAN 10. Which feature caused it, and what does the state tell you?
Show answer
Root Guard caused it. The port received a superior BPDU, meaning another switch is advertising a better bridge ID than the current root. The port stays blocked until those BPDUs stop. Find the switch sending them and either remove it or fix its priority.
Exercise
Why does BPDU Guard go on PortFast ports, and what happens to the port when it triggers?
Show answer
PortFast ports skip listening and learning, so a switch plugged into one could form a loop before spanning tree reacts. BPDU Guard puts the port into err-disabled the moment a BPDU arrives. It stays down until you reset it or errdisable recovery brings it back.