Sub topic 19
Troubleshooting loops and unstable topologies
This chapter assumes you know how switches learn MAC addresses and flood unknown-unicast and broadcast frames. It also assumes you know basic VLANs and trunks, and the STP concepts from earlier chapters: root bridge election, port roles, port states, Rapid PVST+, and the guard features. The commands are Cisco IOS unless noted.
Two kinds of failure
Spanning tree problems fall into two groups. Each group has different symptoms and a different first step.
- A forwarding loop. Some set of ports forwards where it should block. Broadcast and unknown-unicast frames circulate forever because Ethernet frames have no hop limit. The network becomes unusable within seconds.
- An unstable topology. The tree keeps recalculating. Ports change role or state repeatedly, and MAC tables are flushed again and again. Users see intermittent drops and slow traffic, and flooding rises because the MAC tables keep emptying.
Work out which group you are in before you change anything. A loop is an emergency: you must stop it first and diagnose it afterwards. Instability can usually be diagnosed while the network is still partly working.
Recognizing a broadcast storm
A storm shows several symptoms together.
- Switch CPU is near 100 percent, and the console or SSH session is slow or unresponsive.
- Link utilization is near 100 percent on many ports at once, and the LEDs on those ports blink in unison.
- Interface counters for broadcast and multicast packets climb very fast.
- Hosts lose connectivity, DHCP and ARP fail, and applications time out.
- MAC address flapping messages appear in the log, because the same source MAC address is seen on several ports in turn.
A typical flapping message looks like this:
%SW_MATM-4-MACFLAP_NOTIF: Host 0050.7966.6801 in vlan 10 is flapping between port Gi0/1 and port Gi0/2This message is strong evidence of a loop. The same frame arrives on two ports because it traveled around a ring.
First response: stop the loop
When a storm is in progress, restore service first.
- Find the busiest interfaces. Use
show interfaces countersorshow interfaces | include line protocol|input rate|broadcasts, or look at a monitoring graph if you have one. - Disconnect or shut down the redundant link that is closing the loop. Removing a cable is often faster than typing on a congested switch.
- Wait for the storm to drain and for the tree to settle.
- Reconnect links one at a time, and check the spanning tree state after each one.
You can limit the damage of future storms with storm control on access ports. It does not fix a loop, but it keeps the loop from taking down the CPU and the uplinks.
! Cisco IOS: limit broadcast and multicast on an access port
interface GigabitEthernet0/5
storm-control broadcast level 1.00
storm-control multicast level 1.00
storm-control action shutdownCommon causes of loops
Most loops come from a short list of causes. Check them in this order.
| Cause | How it happens | What to check |
|---|---|---|
| Unmanaged switch or hub patched into two wall ports | The small switch does not run STP, so it forwards BPDUs without acting on them and joins two ports of your network. | BPDU Guard on access ports. Look for an err-disabled port. |
| STP disabled | `no spanning-tree vlan N` was entered, or a VLAN is missing from the tree. | `show spanning-tree summary` shows the mode and the VLANs. |
| Unidirectional link | A fiber pair carries traffic in one direction only. The port stops receiving BPDUs and moves to forwarding. | `show spanning-tree inconsistentports` for Loop Guard. Check UDLD, if enabled. |
| BPDU filter in the wrong place | BPDU Filter on a port that is part of a redundant path suppresses the BPDUs the neighbor needs. | `show running-config` for `bpdufilter`. |
| Mismatched modes or trunk settings | Allowed VLAN lists differ at each end of a trunk, so a VLAN has no tree across part of the path. | `show interfaces trunk` on both ends. |
| Bridge or virtual switch created by a host | A server with two NICs bridged in software forwards frames between ports. | Look for a host whose MAC appears behind two switch ports. |
Diagnosing with show commands
Start with the global view, then go to individual ports.
show spanning-tree summary
show spanning-tree vlan 10
show spanning-tree interface GigabitEthernet0/1 detail
show spanning-tree inconsistentportsThe summary tells you the mode, which guards are enabled, and how many ports are in each state for each VLAN. Check the following in show spanning-tree vlan 10:
- Is the root where you expect it? If a new or misconfigured switch with a low priority or an old MAC address became root, the tree changes shape. Traffic then takes paths you did not plan.
- Does every non-root switch have exactly one root port? The output says "This bridge is the root" on the root only.
- Is each segment blocked in exactly one place? A loop means a ring has no blocking port. A segment with no forwarding path means one that blocks too much.
- Are any ports in a state that does not belong? A port stuck in listening or learning, or one flagged as inconsistent, needs attention.
The detail form of the interface command is the most useful for instability. It reports the number of topology changes and when the last one happened. It also names the bridge from which the last topology change notice arrived.
GigabitEthernet0/1 of VLAN0010 is designated forwarding
Number of transitions to forwarding state: 14
BPDU: sent 52301, received 3A port that has sent many BPDUs but received almost none is suspicious. A neighbor that should be sending BPDUs is silent, or the link is damaged in one direction.
Finding the source of topology changes
Each topology change makes switches shorten their MAC aging time and flush entries, so frequent changes cause flooding and brief outages. Use this method to find the origin.
- Run
show spanning-tree vlan 10 detailon any switch. Find the line that gives the number of topology changes, the time since the last one, and "from" followed by an interface. - That interface faces the switch that sent the notice. Log in to that switch and repeat.
- Follow the "from" interface hop by hop until you reach a switch where the change came from a local port.
- That local port is the source. It is usually a flapping link, or a host-facing port that goes up and down.
The usual cause is an access port with a host that reboots, a failing cable, or a port that was not configured with PortFast. On a PortFast edge port, a link change does not generate a topology change. On a port without it, every host reboot does, on every switch in that VLAN.
! Cisco IOS: edge port that will not trigger topology changes
interface GigabitEthernet0/5
switchport mode access
spanning-tree portfast
spanning-tree bpduguard enableUnstable topologies: other causes
- Flapping uplink. A bad optic or cable causes repeated state changes. Check
show interfacesfor input errors and CRC counts, and look at the link flap messages in the log. - Root bridge changes. If the root moves repeatedly, a switch with an equal or better priority is joining and leaving. Set the priority on the intended root and a secondary root deliberately, and use Root Guard where the root must not move.
- Timer mismatch in classic STP. Timers are taken from the root. Do not tune them on other switches, because the root's values override them.
- Mixed modes. A Rapid PVST+ switch connected to a classic PVST+ switch falls back to classic behavior on that link. Convergence on that link is then slow.
- Port errors from guards. BPDU Guard, Root Guard, and Loop Guard each protect against a specific problem. When one fires, the port is not broken. It is reporting a real fault.
Interpreting guard messages
| Message or state | Meaning | Action |
|---|---|---|
| `err-disabled` with BPDU Guard | A BPDU arrived on an edge port. A switch or bridge is attached. | Find and remove the device, then re-enable the port. |
| `*ROOT_Inconsistent*` | A port received a superior BPDU, and Root Guard blocked it. | Find the switch that claims to be root and fix its priority. |
| `*LOOP_Inconsistent*` | A port stopped receiving BPDUs, and Loop Guard blocked it instead of letting it forward. | Check the link in both directions. Look for a unidirectional fault. |
Port recovery is a decision you should make after you understand the cause. Automatic recovery with errdisable recovery cause bpduguard can bring the port back up while the offending device is still plugged in, and you get the loop again.
A worked example
Users in VLAN 10 report outages every few minutes. The log on the distribution switch shows MAC flapping messages, but no sustained storm.
show spanning-tree vlan 10 detailon the distribution switch shows that the last topology change was 12 seconds ago and came fromGigabitEthernet0/24.- On the access switch behind that port, the same command shows the change came from
GigabitEthernet0/9, a local port. show running-config interface GigabitEthernet0/9shows that PortFast is not configured, andshow interfaces GigabitEthernet0/9shows many link resets. A user's docking station is losing power.- The fix is to configure
spanning-tree portfastandspanning-tree bpduguard enableon the port, and to replace the dock. The topology change counter stops increasing.
Troubleshooting checklist
- Classify the problem: loop or instability.
- For a loop, stop it by removing the redundant link, then diagnose.
- Confirm the root bridge and the mode on every switch in the path.
- Count root ports and blocked ports, and look for rings with no blocking port.
- Check the guard state and the err-disabled ports.
- Follow topology change notices back to the originating port.
- Check physical links for errors and one-way failure.
- Reconnect links one at a time and verify after each.
Exercise
A switch log shows repeated "Host 0050.7966.6801 in vlan 10 is flapping between port Gi0/1 and port Gi0/2" messages, and the switch CPU is at 98 percent. What are the first two actions, and why does the order matter?
Show answer
First, stop the loop by disconnecting or shutting down one of the redundant links (for example Gi0/2 if it is an uplink that should be blocking), because a broadcast storm leaves no capacity for diagnosis and keeps the whole VLAN down. Second, once the storm drains, run show spanning-tree vlan 10 and show spanning-tree inconsistentports to find the ring with no blocking port, such as an unmanaged switch or a unidirectional link. Diagnosing first would be slow and unreliable on an overloaded switch.
Exercise
show spanning-tree vlan 10 detail on a switch reports a topology change received on Gi0/1 two seconds ago, and the counter rises every few minutes. How do you find the cause?
Show answer
Follow the notice upstream. Gi0/1 faces the switch that sent the change, so log in to it, run the same command, and read which interface it came from. Repeat until the change originates from a local port. That port is the source. It is typically a flapping link or a host-facing port without PortFast, such as one connected to a rebooting host. Fix the cable or host, and enable PortFast on the edge port.