MAC flooding
MAC flooding is a Layer 2 denial-of-service attack in computer networking that targets Ethernet switches by flooding their Content Addressable Memory (CAM) tables with a large number of fabricated MAC addresses, causing the switch to enter a fail-open mode where it broadcasts all traffic to every port on the network, thereby degrading performance and enabling unauthorized traffic sniffing.[1] This technique, developed in the early 2000s, exploits the limited capacity of a switch's CAM table, which stores mappings between MAC addresses and physical ports to enable efficient frame forwarding (typically holding 4,000 to 64,000 entries in modern hardware as of 2025).[1][2] Attackers commonly use tools such as macof from the dsniff package to generate thousands of dummy Ethernet frames per second, rapidly filling the table and forcing the switch to revert to hub-like behavior.[1]
Fundamentals of Ethernet Switching
MAC Address Learning
A Media Access Control (MAC) address is a 48-bit unique hardware identifier assigned to a network interface controller for use in communications within a network segment.[3] These addresses, standardized by the IEEE 802 committee, consist of 24 bits allocated by the IEEE to manufacturers (Organizationally Unique Identifier) and 24 bits assigned by the manufacturer to ensure global uniqueness.[3]
The process of MAC address learning was introduced with Ethernet bridges in the 1980s to address the limitations of hubs, which broadcast all traffic indiscriminately, leading to inefficiencies in larger networks.[4] Developed by engineers at Digital Equipment Corporation (DEC), bridges improved upon this by dynamically building mappings of MAC addresses to ports, enabling selective frame forwarding and reducing unnecessary traffic.[5]
In modern Ethernet switches, which evolved from these bridges, the learning process operates as follows: upon receiving an Ethernet frame on a port, the switch examines the source MAC address in the frame header and checks its forwarding database.[6] If the source MAC is not already associated with that port, the switch adds a new entry to the database, typically including the MAC address, the ingress port number, and, in VLAN-enabled networks, the associated VLAN identifier. Entries are stored in content addressable memory (CAM) tables for rapid lookup.[6] To maintain accuracy amid network changes, unused entries age out after a default period of 300 seconds, after which they are removed unless refreshed by subsequent frames from the same source.[7]
This learning mechanism plays a crucial role in unicast frame forwarding by allowing the switch to consult the MAC-port mappings and direct frames solely to the destination port, thereby minimizing broadcast traffic and enhancing network efficiency compared to hub-based flooding.[6] Without such learning, switches would revert to broadcasting unknown unicast frames to all ports, increasing collision domains and bandwidth waste.[4]
Content Addressable Memory (CAM) Tables
Content Addressable Memory (CAM) is a specialized hardware component in Ethernet switches designed for ultra-fast lookups by simultaneously comparing an input value—typically a MAC address—against all stored entries in parallel. This associative search mechanism returns the matching entry's associated data, such as the output port, in a single clock cycle, enabling low-latency Layer 2 frame forwarding essential for high-throughput networks.[8] By implementing this in dedicated silicon rather than general-purpose processors, CAM achieves speeds unattainable with software-based alternatives, supporting wire-speed switching even at gigabit rates.[8]
The structure of a CAM table consists of fixed-size entries, each containing the 48-bit MAC address, the corresponding switch port number, VLAN identifier for segmentation support, and an aging timer that records the time since last activity from that address.[9] The aging timer, typically defaulting to 300 seconds, allows automatic removal of stale entries to maintain table efficiency and prevent indefinite accumulation.[9] These tables are populated dynamically through MAC address learning from incoming frame source addresses, with capacities typically ranging from 1,000 to 128,000 entries depending on the switch hardware model.[10]
A key limitation of CAM tables is their finite storage capacity, which can lead to overflow when the number of unique MAC addresses exceeds available entries.[11] In such cases, the switch may discard new learning attempts or revert to a fail-open operational mode, effectively treating the device as a hub for unknown destinations by flooding frames across ports.[11] This hardware constraint underscores the need for careful network design to avoid resource exhaustion.
Compared to software-based forwarding tables in routers, which use sequential searches or hash functions often requiring multiple memory accesses and CPU cycles, CAM excels in Layer 2 environments by providing hardware-accelerated, exact-match lookups optimized for Ethernet's flat addressing model.[8] This distinction highlights CAM's role in bridging the performance gap between legacy hubs and modern switched networks, prioritizing speed over the flexibility of IP routing tables.[8]
The Attack
Mechanism of MAC Flooding
MAC flooding is a denial-of-service attack that exploits the dynamic learning mechanism of Ethernet switches to overflow their Content Addressable Memory (CAM) tables. An attacker must first gain physical or logical access to a switch port within the target local area network (LAN) or virtual LAN (VLAN), allowing them to inject traffic directly into the shared broadcast domain.[12][13] This prerequisite ensures the attacker's frames are processed by the switch alongside legitimate traffic, without requiring elevated privileges or authentication.[12]
The core technique involves the rapid transmission of Ethernet frames containing spoofed, randomly generated source MAC addresses, all originating from the attacker's single connected port. The switch, operating under the IEEE 802.1D bridging protocol, learns these source addresses by associating them with the ingress port and storing them in the CAM table for efficient forwarding.[12][13] As frames arrive, the switch hashes the 48-bit MAC addresses into fixed-size CAM table buckets—typically holding up to 8 entries each—and updates entries dynamically, replacing aged ones (usually after 300 seconds of inactivity). By generating frames at a rate exceeding the table's aging and processing capacity, the attacker fills the CAM table with bogus entries faster than legitimate addresses can be learned or maintained.[12]
Success depends on overwhelming the CAM table's finite capacity, often ranging from 8,000 to 131,000 entries depending on the switch model. The attacker typically needs to generate thousands of unique MAC addresses per second—such as approximately 2,500 per second to fill a mid-range table in under 70 seconds—to achieve overflow.[12] Once the table is full, the switch can no longer learn new addresses and, per IEEE 802.1D specifications, treats frames with unknown destination MAC addresses as broadcasts, flooding them out all ports in the VLAN rather than unicasting to the correct port.[12][13]
Variants of the attack include single-port flooding, where all spoofed frames emanate from one connection, and multi-port flooding if the attacker controls multiple switch ports, accelerating the overflow by distributing the traffic load.[14] Additionally, the technique can be amplified by leveraging ARP spoofing principles, such as sending gratuitous ARP replies with forged MAC addresses, which not only populate the CAM table but also trigger additional network responses that indirectly increase the flood volume.[13] This exploitation relies solely on the standard, unauthenticated frame-learning process defined in IEEE 802.1D, making it applicable to any compliant Ethernet switch without proprietary modifications.[12]
One of the primary tools for executing MAC flooding attacks is macof, part of the dsniff suite developed by Dug Song. This utility generates and transmits a high volume of Ethernet frames containing random source MAC addresses, typically at rates up to 8,000 frames per second, to overwhelm the switch's Content Addressable Memory (CAM) table.[15][16] As a result, vulnerable switches may enter a fail-open mode, broadcasting all traffic and enabling passive sniffing.[15]
Alternatives to macof include packet crafting libraries such as Scapy, a Python-based tool for generating custom network packets, and Ettercap, which supports man-in-the-middle techniques that can incorporate MAC address manipulation. Scapy allows users to forge Ethernet frames with spoofed MAC addresses, offering flexibility for tailored flooding scenarios beyond simple randomization. Ettercap, while primarily focused on ARP-based attacks, can be extended for custom frame injection in Layer 2 environments.[17][18]
To implement a MAC flooding attack using Scapy, an attacker requires root privileges on a Linux system to access raw sockets, which enable direct packet transmission without kernel intervention. The process involves importing the library, generating random MAC addresses, and sending Ethernet frames in a loop until the CAM table overflows. For example, the following pseudocode illustrates basic frame generation:
from scapy.all import *
import random
def random_mac():
return ':'.join(['%02x' % random.randint(0, 255) for _ in range(6)])
while True:
pkt = Ether(src=random_mac(), dst="ff:ff:ff:ff:ff:ff") / [IP](/page/IP)() / ICMP()
sendp(pkt, iface="eth0", inter=0)
from scapy.all import *
import random
def random_mac():
return ':'.join(['%02x' % random.randint(0, 255) for _ in range(6)])
while True:
pkt = Ether(src=random_mac(), dst="ff:ff:ff:ff:ff:ff") / [IP](/page/IP)() / ICMP()
sendp(pkt, iface="eth0", inter=0)
This script floods the network interface (e.g., eth0) with broadcast frames using randomized source MACs, simulating the overload mechanism.[19][20]
Advanced techniques enhance the attack's scope and stealth. Attackers often combine MAC flooding with ARP poisoning—using tools like arpspoof from the dsniff suite—to create targeted floods that redirect specific traffic flows after the switch fails open, allowing selective interception. Additionally, deploying multiple virtual machines (VMs) or network interface cards (NICs) amplifies the flood rate; for instance, running macof across several Kali Linux VMs on a hypervisor like Open vSwitch can distribute the packet generation, overwhelming virtual or physical switches more rapidly.[16][21]
The macof tool was developed by Dug Song in the early 2000s as part of the dsniff suite for network auditing purposes. It remains effective against unpatched legacy switches in 2025, particularly in environments lacking modern port security features.[15][22]
Consequences
Network Behavior After Flooding
When a switch's Content Addressable Memory (CAM) table overflows due to a MAC flooding attack, it typically enters a fail-open mode, where it floods all incoming unicast frames out of every port in the affected VLAN, mimicking the behavior of a hub rather than a switch.[23][24] This hub-like operation expands the effective broadcast domain, as frames are replicated unnecessarily across all ports, leading to increased network traffic volume.[25]
The performance degradation is significant, with substantial bandwidth waste occurring from the replication of traffic to unintended ports, reducing overall throughput and increasing latency for legitimate communications.[23] If spanning tree protocol loops are present in the network topology, this flooding can exacerbate issues by triggering broadcast storms, where frames continuously circulate and amplify, potentially overwhelming the network and causing complete denial of service.[26]
The disruption is generally temporary, lasting until the forged MAC entries age out of the CAM table; the default aging time on many switches, such as Cisco models, is 300 seconds (5 minutes), after which the table begins to recover as legitimate addresses are relearned.[27] However, repeated or sustained attacks can prevent recovery, resulting in persistent performance issues until the attack ceases.[28]
The effects are confined to the specific VLAN targeted by the flood, as switches maintain separate CAM tables per VLAN, leaving other VLANs, routed traffic, and higher-layer protocols unaffected unless the attack is combined with inter-VLAN exploits.[23][25]
Security Vulnerabilities
When a switch's MAC address table is overwhelmed during a MAC flooding attack, it enters a fail-open mode, broadcasting all incoming unicast traffic to every port on the network segment, effectively turning the switch into a hub.[29] This condition exposes all traffic to passive sniffing by an attacker connected to any port, allowing the interception of sensitive data such as login credentials, session tokens, and personal information transmitted over the local area network (LAN).[30] The primary risk lies in this unauthorized access to unicast communications, which were intended to be isolated by the switch's learning mechanism.[31]
The exposure created by MAC flooding significantly escalates potential threats, serving as an entry point for more sophisticated attacks. For instance, intercepted packets can facilitate man-in-the-middle (MITM) interceptions, where the attacker relays and alters traffic between victims, or session hijacking, enabling the takeover of active user sessions.[32] Further exploitation may involve using captured data to deploy malware, such as through credential stuffing to gain elevated access on compromised hosts.[33]
Unencrypted protocols are particularly susceptible in this scenario, as their plaintext payloads become fully readable during the broadcast phase. Protocols like HTTP for web traffic and FTP for file transfers transmit data without encryption, making them prime targets for capturing usernames, passwords, and file contents.[34] Even encrypted protocols, such as HTTPS or SFTP, reveal valuable metadata—including source and destination IP addresses, MAC addresses, and traffic patterns—that can aid in profiling network users or planning subsequent attacks.[35]
In real-world contexts, MAC flooding remains a notable vulnerability in legacy or misconfigured enterprise networks, where older switches without modern protections are prevalent.
Mitigation Strategies
Switch Configuration Protections
Switch configuration protections against MAC flooding primarily involve features that directly limit the abuse of the content addressable memory (CAM) table on Ethernet switches, preventing attackers from overwhelming it with fabricated MAC addresses. One key mechanism is port security, which restricts the number of MAC addresses that can be learned on a specific port, thereby mitigating attempts to flood the table. For instance, administrators can configure a maximum of 1 to 5 MAC addresses per port, depending on the expected device connections, such as limiting end-user ports to a single address for stationary devices.[36] This feature can employ sticky learning, where dynamically learned MAC addresses are retained and saved in the switch's configuration, ensuring only authorized addresses are permitted without manual entry.[36] Upon violation, such as detecting excess MAC addresses, the switch can take actions like port shutdown, which error-disables the interface, or restrict mode, which drops offending packets while allowing legitimate traffic to continue and logging the event.[36] In Cisco IOS, this is implemented with commands such as switchport port-security maximum 1 to set the limit and switchport port-security violation restrict to define the response.[36]
Another protective measure is rate limiting through storm control, which throttles excessive incoming frames on a per-port basis to curb rapid flooding that could overflow the MAC table. This feature monitors broadcast, multicast, and unicast traffic, suppressing it when it exceeds a configured threshold, typically set at 10-50% of the port's bandwidth to balance security and performance.[37] For example, in environments prone to MAC flooding, a threshold of 5% for broadcast traffic prevents the switch from processing overwhelming volumes of frames, thereby avoiding the unicast flooding that occurs post-table saturation.[37] Cisco's implementation uses commands like storm-control broadcast level 5.00, which drops packets exceeding the percentage over a one-second interval while allowing resumption below the threshold.[37] This directly counters the mechanism of MAC flooding by limiting the rate at which bogus frames can be injected.[38]
VLAN segmentation further enhances switch-level defenses by isolating traffic into separate broadcast domains, confining any potential flooding to a limited subset of ports and reducing the overall attack surface. By assigning devices to appropriate VLANs, switches ensure that MAC learning and flooding are scoped per VLAN, preventing a flood in one segment from affecting others.[39] Private VLANs (PVLANs) provide additional granularity within a VLAN, using primary and secondary associations—such as isolated or community ports—to block direct inter-port communication, which minimizes the propagation of flooded frames among untrusted devices.[39] This isolation is particularly effective in shared environments like data centers, where it limits the impact of MAC table abuse without requiring full network redesign.[39]
Network-Level Defenses
Dynamic ARP Inspection (DAI) is a protocol-based security feature that validates Address Resolution Protocol (ARP) packets on untrusted ports by cross-referencing them against a trusted binding database, typically derived from DHCP snooping, to ensure legitimate MAC-IP address mappings.[39] This mechanism blocks forged ARP replies that could exploit the indiscriminate traffic forwarding caused by a successful MAC flooding attack, thereby preventing subsequent ARP spoofing and man-in-the-middle intrusions across the local area network (LAN).[39] DAI operates by intercepting ARP requests and replies, dropping invalid packets, and logging violations, which helps maintain network integrity without relying solely on switch-level configurations.[39]
DHCP Snooping complements DAI by monitoring DHCP traffic to construct and maintain a binding table of valid client MAC addresses, IP addresses, ports, and VLAN assignments, filtering out unauthorized or rogue DHCP messages from untrusted sources.[39] This table serves as the authoritative source for DAI validation, discarding packets with mismatched or spoofed MAC-IP bindings that might arise from the hub-like behavior induced by MAC flooding.[39] By rate-limiting DHCP offers and acknowledgments on untrusted ports, DHCP Snooping prevents resource exhaustion attacks that could indirectly facilitate MAC table overflows, ensuring only legitimate assignments propagate through the LAN.[39]
Network-based Intrusion Detection Systems (IDS), such as Snort, provide monitoring capabilities to detect MAC flooding by analyzing traffic for anomalous patterns, including high rates of unique source MAC addresses or excessive frame volumes indicative of CAM table saturation.[40] These systems use rule-based engines to match log entries or packet signatures— for instance, patterns like repeated MAC lock violations on specific interfaces—triggering alerts for rapid MAC address generation that exceeds normal thresholds.[40] In a LAN environment, IDS deployment at strategic points enables real-time anomaly detection, allowing administrators to isolate affected segments before widespread disruption occurs. Recent advancements include machine learning-based IDS, such as BCAST IDS, which detect broadcast-related anomalies indicative of MAC flooding with high accuracy in environments like connected vehicles.[41]
Adopting best practices like network segmentation using VLANs and firewalls limits the blast radius of a MAC flooding attack by confining broadcast domains and enforcing inter-segment traffic controls, reducing the potential for lateral movement or amplified flooding effects.[16] Endpoint encryption protocols, such as IPsec, further mitigate risks by securing data in transit, rendering intercepted traffic unreadable even if a flooded switch reverts to promiscuous mode and enables eavesdropping.[42]