MAC address flapping between ports: causes and the fix
MAC address flapping occurs when a switch's MAC address table shows the same device MAC repeatedly moving between different ports within seconds or minutes. This instability causes packet loss, network loops, or forwarding failures that degrade user experience and complicate troubleshooting. Understanding the root causes and applying systematic fixes is essential for maintaining a stable switched network.
What is MAC address flapping?
A switch learns MAC addresses by observing the source MAC in frames arriving on each port. Normally, a MAC address remains associated with one port until the device moves or the aging timer expires. MAC flapping is when the switch's MAC address table shows the same MAC address appearing on different ports repeatedly. The switch updates its forwarding table each time, creating instability that breaks unicast forwarding and can trigger broadcast storms.
You can observe MAC flapping using 'show mac address-table dynamic' or 'show mac-address-table' commands on most vendors. Look for entries where the port changes frequently in successive command outputs, or enable MAC notification traps to log changes in real time.
Common causes of MAC address flapping
- →Spanning Tree Protocol (STP) reconvergence: Root bridge election or topology changes cause temporary loop conditions where frames arrive on multiple ports.
- →Unidirectional link failures: A link may transmit but not receive, causing the switch to see the same MAC on a backup path and then the primary path alternately.
- →Duplicate MAC addresses: Two devices configured with the same MAC (rare but possible in virtual environments or misconfigured appliances) generate conflicting learn events.
- →Port mirroring or SPAN sessions: Traffic copied to a monitor port can cause the switch to learn source MACs from the mirrored traffic, appearing to move between the real port and mirror port.
- →Faulty network interface cards (NICs): A NIC that transmits intermittently or with corrupted frames can cause the switch to alternate between learning the MAC and timing it out.
- →Rapid topology changes: Frequent link flaps, device reboots, or failover events trigger repeated MAC learning on different ports.
Troubleshooting and resolution steps
Start by identifying which MAC address is flapping and on which ports. Enable MAC notification or use SNMP traps to capture the movement pattern. Then verify the physical and logical topology:
- →Check for loops: Run 'show spanning-tree' to confirm STP is converged and no redundant paths are active. Look for blocked ports and ensure the root bridge is stable.
- →Verify link status: Confirm both ends of each port are up and negotiated correctly. Check for errors, CRC, or collisions using 'show interfaces' counters.
- →Inspect device configuration: Confirm the device's MAC address matches what the switch is learning. Check for DHCP or IP conflicts that might trigger rapid reconnections.
- →Review port configuration: Disable port mirroring or SPAN sessions temporarily to rule them out. Verify VLAN assignments are correct and consistent.
- →Check for duplicate MACs: Use 'show mac address-table | include <MAC>' across all switches to identify if the address exists legitimately elsewhere.
- →Isolate the device: Move the suspected device to a clean port with no mirroring or special configuration. If flapping stops, the issue is environmental.
- →Validate NIC and driver: On the end device, check for driver updates, NIC firmware issues, or hardware errors. Test with a different NIC if possible.
Prevention and best practices
Implement these practices to reduce MAC flapping incidents:
- →Tune STP timers: Use RSTP (Rapid STP) or MST for faster convergence and fewer transient loops.
- →Monitor MAC address table changes: Enable syslog or SNMP notifications to alert on rapid MAC movements.
- →Validate MAC address uniqueness: Enforce unique MAC addresses in your environment, especially in virtual and cloud deployments.
- →Avoid unnecessary port mirroring: Use SPAN only when needed and document which ports are mirrors.
- →Maintain device health: Keep NIC drivers and firmware current. Monitor device CPU and memory to prevent erratic behavior.
- →Document your topology: Maintain accurate records of physical connections and VLAN assignments to speed troubleshooting.
MAC address flapping is a symptom, not a disease. Systematic investigation of the physical topology, device configuration, and switch state will reveal the root cause. Once identified, most flapping issues resolve quickly through topology correction, device repair, or configuration adjustment.