CCNA Lab 7: Loop Troubleshooting and STP Deep Dive
A Layer 2 loop is the fastest way to destroy a network. Broadcast frames circulate at wire speed, switches fill their CAM tables, and every port saturates. Spanning Tree Protocol (STP) prevents loops — when it fails, you have seconds to act.
STP elects a root bridge and blocks redundant ports to create a loop-free topology.
| State | Purpose |
|---|---|
| Blocking | No data, no learning, no BPDU processing |
| Listening | No data, no learning, sending/receiving BPDUs |
| Learning | No data, learning MAC addresses |
| Forwarding | Full operation |
| Disabled | Administratively down |
| Role | Description |
|---|---|
| Root Port (RP) | Best path to root bridge (one per non-root switch) |
| Designated Port (DP) | Best path on a segment (one per segment) |
| Alternate Port (AP) | Backup path to root bridge |
Symptoms of a Layer 2 loop:
%SW_MATM-4-MACFLAP_NOTIF: Host 0050.7966.6800 in vlan 10 is flapping between port Gi0/1 and port Gi0/2
When you suspect a loop:
# 1. Identify the flapping MAC addresses
show mac address-table | include flapping
# 2. Check CPU utilization
show processes cpu sorted
# 3. Check port utilization
show interfaces | include rate|line
# 4. Look for high broadcast rates
show interfaces Gi0/1 | include broadcastIf the network is down and you need to break the loop right now:
! Disable all ports except the management uplink
interface range Gi0/1-24
shutdown
! Re-enable one port at a time
no interface Gi0/1 shutdown
! Wait 30 seconds
no interface Gi0/2 shutdown
! Continue until the loop returnsWhen the loop returns, the last port you enabled is involved in the loop.
show spanning-tree
show spanning-tree vlan 10
show spanning-tree detail
show spanning-tree root
show spanning-tree blockedports
show spanning-tree vlan 10 bridgeshow spanning-tree root
Root ID Priority Cost Root Port
VLAN0001 32769 32769 19 Gi0/24
VLAN0010 32778 32778 19 Gi0/24
VLAN0020 32788 32788 19 Gi0/24If a switch in the access layer is the root bridge instead of the core switch, the path is suboptimal.
show spanning-tree blockedports
Name Blocked Interfaces List
-------------------- --------------------------
VLAN0001 Gi0/3
VLAN0010 Gi0/3
VLAN0020 Gi0/3A healthy network should have blocked ports (that means STP is working). If no ports are blocked in a redundant topology, a loop exists somewhere.
When a port transitions to forwarding, STP sends a Topology Change Notification (TCN). Excessive TCNs destabilize the network:
show spanning-tree detail | include topologyPrevent an unauthorized switch from becoming root bridge:
interface Gi0/24
spanning-tree guard rootIf a superior BPDU is received on this port, it goes into root-inconsistent (blocking) state.
Shut down a port that receives BPDUs (useful on access ports where end users should not be connecting switches):
interface Gi0/1
spanning-tree bpduguard enableOr globally:
spanning-tree portfast bpduguard defaultPut access ports into forwarding state immediately:
interface Gi0/1
spanning-tree portfastNever enable PortFast on trunk ports.
Prevents alternate/root ports from transitioning to forwarding when BPDUs stop:
interface Gi0/24
spanning-tree guard loopDetects fiber issues where one direction of a link fails:
udld enable
interface Gi0/24
udld port aggressive1. ssh to core switch
2. show processes cpu | include CPU
CPU utilization for five seconds: 95%, one minute: 90%, five minutes: 85%
3. show interfaces | include broadcast
Gi0/1: Broadcast 452312 packets/sec
4. show mac address-table count
Dynamic Address Count: 23000
(Normal is ~500 on this network)The high MAC count and broadcast rate confirm a loop. Break the loop by shutting down the port with the highest broadcast rate.
Intermittent disconnects with MACFLAP_NOTIF messages:
%SW_MATM-4-MACFLAP_NOTIF: Host aaaa.bbbb.cccc in vlan 10 is flapping between port Gi0/1 and port Gi0/2Causes:
debug spanning-tree events
debug spanning-tree bpduWatch for unexpected TCNs:
STP: VLAN0010 new root port Gi0/24, cost 19
STP: VLAN0010 Gi0/24 -> listening
STP: VLAN0010 Gi0/24 -> learning
STP: VLAN0010 Gi0/24 -> forwarding
A healthy network should be quiet. Constant STP changes indicate a problem.
| Timer | Default | Recommendation |
|---|---|---|
| Hello | 2 sec | Keep default |
| Forward Delay | 15 sec | Keep default |
| Max Age | 20 sec | Keep default |
| Convergence | ~50 sec | Reduce with Rapid PVST+ |
Rapid PVST+ converges in 1-3 seconds vs 50 seconds for classic STP:
spanning-tree mode rapid-pvstCompatible with classic STP — switches running RSTP fall back to 802.1D when connected to legacy STP switches.
Related Articles
CCNA Lab 7: Loop Troubleshooting and STP Deep Dive
Identify and fix Layer 2 loops, analyze STP topology changes, and use debug commands to find the source of broadcast storms.
CCNA Lab 14: Network Health Checks, BKMs, and Command Reference
Daily, weekly, and monthly health checks for your switches. Best known methods, maintenance procedures, and a comprehensive command reference for L2 engineers.
CCNA Lab 12: DHCP Snooping, DAI, and IP Source Guard
Configure Layer 2 security features to prevent DHCP spoofing, ARP poisoning, and IP spoofing attacks on your access switches.