ARP Spoofing and Man-in-the-Middle: Attacks at Layer 2
How ARP spoofing works, why it is dangerous on local networks, how it enables man-in-the-middle attacks, and how to detect and prevent it.
ARP spoofing is one of the classic attacks most often found on local networks. It looks simple, but its impact is huge: an attacker can read, modify, or cut off the communication between you and another device without you ever noticing.
What Is ARP?
Before understanding the attack, get to know the protocol first. ARP (Address Resolution Protocol) is the protocol that translates IP addresses into MAC addresses (a device’s physical address).
When computer A wants to reach computer B on the same network, it asks the entire network:
"What is the MAC address for IP 192.168.1.10?"
The device that knows the answer replies, and then every device stores this answer in a cached ARP table. This process runs continuously every time there is new communication.
How ARP Spoofing Works
The fundamental problem with ARP: it has no verification mechanism. Anyone can send an ARP reply claiming to own a particular IP.
An attacker on the same network sends an ARP packet with forged contents:
"192.168.1.10 (target)'s MAC is my MAC"
The victim’s ARP table then contains the attacker’s MAC address for the target IP. From that point on, all data the victim sends to the target will first be routed through the attacker, even though the victim thinks it is sending directly to the target. This is the foundation of man-in-the-middle (MITM).
What Can an Attacker Do?
- Eavesdrop on the contents of unencrypted conversations (for example HTTP, telnet, legacy FTP).
- Modify data in transit before forwarding it.
- Impersonate services (for example impersonating the gateway so that login passwords fall into the attacker’s hands).
- Deliberately drop the target’s connections (a small denial of service).
One thing that is often forgotten: HTTPS and SSH remain safe from content reading, because the data is encrypted. ARP spoofing steals the position of the traffic, not the encryption. This is a strong reason why every modern web service must use HTTPS.
How to Detect It
Some symptoms you can look for:
- The ARP table contains duplicate MACs: two different IPs with the same MAC is a classic sign of spoofing.
# View the ARP table on Linux
arp -a
# On Windows
arp -a
- In Wireshark: the
arpfilter shows many varying replies coming from a single IP. - Duplicate IP detection: some systems issue an “IP conflict” warning that is often a trace of spoofing.
How to Prevent It
| Method | How It Works |
|---|---|
| Port security on the switch | The switch only allows 1-2 MACs on a single port, so an attack on the cable dies on its own |
| Static ARP | ARP entries are entered manually and no dynamic ARP replies are accepted |
| DAI (Dynamic ARP Inspection) | The switch validates ARP packets against a list of legitimate IP-MAC pairs |
| Encrypt all traffic | HTTPS, SSH, VPN: the contents stay safe even if the traffic’s position is stolen |
| 802.1X | A device must authenticate before it can access the network (covered in another article) |
For a homelab, the most realistic combination is segmentation + traffic encryption. On a small home network where all devices are trusted, the risk of ARP spoofing is low, but understanding the concept still matters because it is the foundation of many advanced attacks.
Curriculum next step: from an attack on a single device to a mass attack, learn about types of DoS and DDoS attacks and their mitigation.
References
- RFC 826, An Ethernet Address Resolution Protocol, rfc-editor.org/rfc/rfc826 (the original ARP specification).
- RFC 5227, IPv4 Address Conflict Detection, rfc-editor.org/rfc/rfc5227 (duplicate addresses related to spoofing).
- Chris Sanders, Practical Packet Analysis, No Starch Press (chapter on ARP detection).
- Cisco, Dynamic ARP Inspection Configuration Guide, documentation.cisco.com (DAI concepts).
Related Articles
Network Security Fundamentals: The CIA Triad and Threat Modeling
Learn the foundations of network security from scratch: the CIA Triad, essential terms, and how to think through a threat model.
SecurityWhy Learning Networking Is a Mandatory Prerequisite for Understanding Hacking
Hackers and security analysts share one foundation: understanding how data flows across networks, which is why networking must come before hacking.
SecurityHardening Homelab Server Security: A Complete Guide
Secure your homelab server with essential hardening steps from SSH key authentication to service isolation and automated updates using this practical checklist.
Your ideas deserve to be read by thousands of people.
ByteNesia is built for everyone. If you have experience, tutorials, or opinions about technology, write and share them here. Your name will be credited as a contributor.
Write anything: tool reviews, homelab tutorials, security tips, or your tech stories.