The ARP protocol

  1. Quick summary
  2. Step 1 — Check the ARP cache before sending a frame
  3. Step 2 — Send the ARP Request broadcast
  4. Step 3 — Receive the unicast ARP Reply
  5. Step 4 — Pinging the Internet: ARP for the gateway
  6. Step 5 — ARP spoofing: poisoning the cache
  7. Step 6 — Watch ARP directly with Wireshark/tcpdump
  8. Step 7 — Gratuitous ARP and IP conflict detection
  9. Common misconceptions
  10. Practice at home
  11. Review questions
  12. Flashcards

Estimated time: 30 minutes.

Quick summary

Step 1 — Check the ARP cache before sending a frame

The Linux kernel checks the ARP table (ip neigh) before sending a broadcast. If the cache entry is still valid → it is used right away, with no broadcast.

A cache hit = saves ~1ms and avoids bothering the whole LAN.

When it breaks: An ARP cache entry in FAILED after a flush → ping fails with 'Destination Host Unreachable' even though the host is still alive.

The kernel will retry ARP automatically but with some latency. When debugging 'intermittent connection loss': check the ip neigh state first.

# Show the current ARP cache table
ip neigh show

# Sample output:
# 192.168.1.1 dev eth0 lladdr aa:bb:cc:dd:ee:01 REACHABLE
# 192.168.1.10 dev eth0 lladdr aa:bb:cc:dd:ee:10 STALE

Observe with:

ip neigh show  # Show the whole cache with state
ip neigh show nud reachable  # Only entries that are reliable
watch -n2 'ip neigh show'  # Watch cache changes in real time

Step 2 — Send the ARP Request broadcast

When the cache has no MAC for the destination IP,

the host sends an ARP Request as a broadcast (Ethernet dst ff:ff:ff:ff:ff:ff) asking the whole LAN who holds that IP. sudo tcpdump -i eth0 -n arp shows this request as an 'arp who-has' line,

while arping lets you send a request to an IP yourself to see whether a reply comes back.

Seeing a Request with no Reply means the problem is on the target side, not the sender.

When it breaks: No ARP Reply after the Request → the host does not exist, is off, or has ARP disabled (some firewall configs).

To tell them apart: if you see the broadcast Request but no Reply → the problem is on the target side, not the sender.

# Watch ARP broadcasts on the wire with tcpdump
sudo tcpdump -i eth0 -n arp

# Or use arping to send an ARP request manually
sudo arping -I eth0 -c 1 192.168.1.10

Observe with:

sudo tcpdump -i eth0 -n arp  # See 'arp who-has' (request) and 'arp reply' (reply)
# Request: Ethernet dst=ff:ff:ff:ff:ff:ff (broadcast)
# Reply: Ethernet dst=<MAC of the asker> (unicast)
sudo arping -I eth0 -c 1 192.168.1.10  # Test ARP manually, see whether there is a reply

Symptoms when it breaks:

How to fix:

  1. Identify the source of the storm: count the ARP rate on the switch port or with tcpdump

sudo tcpdump -i eth0 -n arp | awk '{print $NF}' | sort | uniq -c | sort -rn | head -20
  1. Isolate the suspect port on the managed switch to stop the storm

sudo ip link set eth0 down  # temporarily isolate the interface that is flooding

Step 3 — Receive the unicast ARP Reply

The target machine sends a unicast Reply back: 'IP 192.168.1.10 has MAC aa:bb:cc:dd:ee:10'. It is unicast because the Request already supplied the asker's MAC — no broadcast is needed.

The kernel stores it in the cache immediately.

When it breaks: After flushing the cache and a successful ping: ip neigh show must show a new entry with state REACHABLE.

If it is still FAILED after a successful ping → ARP works but something is wrong with the neighbor subsystem (rare, usually a kernel bug or container network misconfiguration).

# Watch the cache being updated after a ping
ip neigh flush all           # Clear the cache
ping -c 1 192.168.1.10       # Trigger ARP
ip neigh show                # See the newly added entry

Observe with:

ip neigh flush all && ping -c 1 192.168.1.10 && ip neigh show
# After this command: you see the entry 192.168.1.10 REACHABLE with the correct MAC
# Timing: ARP resolution happens in <1ms when the host is alive

Step 4 — Pinging the Internet: ARP for the gateway

When you ping an address outside the subnet such as 8.8.8.8, the kernel does not ARP for that IP itself but consults the routing table to get the next hop.

With default via 192.168.1.1, an ARP Request is sent to ask for the gateway's MAC, and the frame carrying the ping packet is sent to that MAC.

Running tcpdump alongside the ping shows a request asking for the gateway IP, not 8.8.8.8.

When it breaks: ip neigh flush + ping 8.8.8.8: tcpdump must show an ARP request for 192.168.1.1, not 8.8.8.8.

If you do not see an ARP for the gateway → the routing table is wrong (no default route) → 'Network unreachable' instead of an ARP timeout.

# Look at the routing table to understand how the kernel decides the next hop
ip route
# Output: default via 192.168.1.1 dev eth0

# When pinging 8.8.8.8 → ARP happens for 192.168.1.1
sudo tcpdump -i eth0 arp &
ping -c 1 8.8.8.8
kill %1

Observe with:

ip route  # Look for 'default via X.X.X.X' — this is the IP that gets ARPed
sudo tcpdump -i eth0 arp -n  # Capture alongside while pinging 8.8.8.8
# Confirm: the ARP request asks for the gateway IP, not 8.8.8.8

Step 5 — ARP spoofing: poisoning the cache

ARP has no authentication mechanism: any machine can send a Reply claiming to own an IP, and other hosts may update their cache accordingly.

An attacker exploits this to poison the cache and make traffic flow through their machine (MITM).

An easy sign to spot is two different IPs in the cache pointing to the same MAC — detect it with ip neigh show | awk '{print $5}' | sort | uniq -d or arp-scan --localnet.

When it breaks: ARP does not authenticate the sender — any machine can claim any IP. This is a by-design weakness of RFC 826.

You cannot 'patch' ARP — you must defend at another layer (switch DAI, VPN, TLS).

# Detect ARP spoofing with arp-scan or by looking for anomalies
# (on Linux - for learning only, do NOT use for real attacks)
arp -a | sort -t'.' -k4 -n  # View the whole cache, look for duplicate MACs

# Detection: 2 IPs with the same MAC = a sign of spoofing
# ip neigh | awk '{print $5}' | sort | uniq -d

Observe with:

ip neigh show | awk '{print $5}' | sort | uniq -d  # Find duplicate MACs
# If there is output → 2 IPs share 1 MAC → a sign of spoofing or NIC bonding
arp-scan --localnet  # Scan ARP across the whole LAN, compare MACs with what you expect

Symptoms when it breaks:

How to fix:

  1. Confirm the gateway's real MAC by asking the switch directly or comparing against a baseline

sudo arping -I eth0 -c 2 192.168.1.1 | grep 'reply from'
  1. Delete the poisoned ARP cache entry and force a re-resolve

sudo ip neigh del 192.168.1.1 dev eth0 && ping -c 1 192.168.1.1
  1. Add a static ARP entry for the gateway to block further spoofing (temporary)

sudo ip neigh add 192.168.1.1 lladdr aa:bb:cc:dd:ee:01 dev eth0 nud permanent

Scripting it: Cron: */5 * * * * /usr/local/bin/arp-monitor.sh eth0. Requires the arp-scan package. Log to syslog for centralized alerting.

#!/bin/bash
# Detect duplicate MACs (an ARP spoofing indicator) on the LAN
# Uses arp-scan, run from cron every 5 minutes
INTERFACE=${1:-eth0}
DUPS=$(sudo arp-scan --interface="$INTERFACE" --localnet 2>/dev/null \
  | awk '/DUP/{print $1, $2}' | sort -u)
if [ -n "$DUPS" ]; then
  echo "[ALERT $(date '+%Y-%m-%d %H:%M:%S')] Duplicate MAC detected on $INTERFACE:"
  echo "$DUPS"
  logger -t arp-monitor "ALERT: duplicate MAC — $DUPS"
fi

Step 6 — Watch ARP directly with Wireshark/tcpdump

Hands-on capture is the only way to truly see ARP at work. The Wireshark filter 'arp' isolates it completely. What to observe: Dst broadcast → Request; Dst unicast → Reply.

This is core knowledge when debugging 'host unreachable'.

When it breaks: Running tcpdump on the wrong interface (vlan vs physical, docker0 vs eth0) → you see no ARP even though it is happening.

In Docker/Kubernetes: ARP happens on virtual interfaces (veth, docker0, cni0), not eth0.

# Terminal 1: Capture ARP
sudo tcpdump -i eth0 -n -vvv arp

# Terminal 2: Flush the cache and then ping to trigger ARP
ip neigh flush all
ping -c 1 192.168.1.10

# Wireshark filter: arp
# Look for: Who has 192.168.1.10? Tell 192.168.1.5

Observe with:

sudo tcpdump -i eth0 -n -vvv arp  # -vvv to see the full ARP fields
# Read: 'arp who-has TARGET tell SENDER' = Request
# Read: 'arp reply TARGET is-at MAC' = Reply
ip link show  # List all interfaces — pick the right interface

Step 7 — Gratuitous ARP and IP conflict detection

When an interface comes up, Linux sends a Gratuitous ARP by itself: a broadcast '192.168.1.5 has MAC ...'.

Purpose: (1) update every machine's cache with the new MAC, (2) detect an IP conflict — if anyone replies, two machines share the same IP.

This is also the mechanism used for VIP failover (VRRP/keepalived).

When it breaks: After a keepalived failover with no Gratuitous ARP sent → hosts on the LAN keep the old cache (the primary node's MAC) → traffic to the VIP still goes to the node that is down → downtime lasts until the cache expires (~5 minutes).

Gratuitous ARP is a mandatory step in failover.

# Send a Gratuitous ARP manually (for example after a failover)
arping -A -I eth0 -c 3 192.168.1.5

# Or use arping to check for an IP conflict:
arping -D -I eth0 192.168.1.5
# Exit code 1 = conflict

Observe with:

sudo tcpdump -i eth0 arp  # See the Gratuitous ARP when running arping -A
# Gratuitous: sender IP = target IP (the host asks about its own address)
arping -D -I eth0 192.168.1.5  # Duplicate Address Detection: exit 1 = conflict

Common misconceptions

Right: An ARP Request is a broadcast (Ethernet dst=FF:FF:FF:FF:FF:FF) sent to the entire broadcast domain; only the host whose IP matches sends a unicast Reply back.

See RFC 826 §2.

Getting this wrong makes you unable to debug 'no ARP reply' — if VLAN isolation is wrong or the broadcast domain is split, the ARP Request never reaches the target even though IP routing is fine.

Check with tcpdump -n arp to see the actual broadcast frame.

Right: The kernel consults the routing table to determine the next hop; if 8.8.8.8 is outside the subnet, ARP is sent for the default gateway's IP, not 8.8.8.8.

RFC 826 confines ARP to the broadcast domain — IPs outside the subnet have no ARP entry.

Getting this wrong leads to debugging the firewall at the wrong layer: seeing 'no ARP for 8.8.8.8' and assuming a routing fault, when in fact the gateway ARP is what is failing.

Use ip neigh show | grep gateway-IP to pin it down correctly.

Right: The Linux neighbor cache follows the state machine of RFC 4861 §7.3: REACHABLE (~30s) → STALE → DELAY → PROBE → FAILED; the kernel expires and re-verifies entries by itself when needed.

A STALE entry is normal — there is no need to flush manually.

Not knowing that STALE is a normal state leads to flushing the ARP cache needlessly, which causes a small broadcast storm on a large LAN.

Only flush when an entry is FAILED and you need to force a re-resolve.

Right: ARP has 2 opcodes: Request (opcode=1) and Reply (opcode=2) per RFC 826 §3.

There is also Gratuitous ARP — a host sends an ARP Request or Reply asking or answering for its own IP to update caches and detect IP conflicts, defined in RFC 5227 §2.

Not distinguishing Gratuitous ARP leads to misreading tcpdump when debugging a failover: seeing an ARP Reply with no preceding Request is normal in a VRRP/keepalived failover — it is not ARP spoofing.

Right: ARP is an L2 protocol, and broadcasts do not cross routers (RFC 826).

Each subnet has its own ARP broadcast domain; a router forwards packets by IP routing and does not use ARP across subnets. Proxy ARP is a special feature that a router opts into, not the default.

Getting this wrong leads to a bad VPC design: creating a /16 subnet for the whole datacenter and expecting ARP to resolve across racks — in reality you need L3 routing between /24s.

Kubernetes nodes also need to be in the same broadcast domain for ARP to work.

Practice at home

1. Observe ARP Request/Reply directly on the wire — see the broadcast and the unicast with your own eyes

# Flush the cache first to make sure there is a fresh ARP exchange
sudo ip neigh flush all

# Capture ARP in terminal 1
sudo tcpdump -i eth0 -n -vvv arp

# In terminal 2: ping to trigger it
ping -c 1 192.168.1.1

Observation: # Request: Ethernet dst=ff:ff:ff:ff:ff:ff (broadcast) # 'arp who-has 192.168.1.1 tell 192.168.1.5' # Reply: Ethernet dst=<MAC requester> (unicast) # 'arp reply 192.168.1.1 is-at aa:bb:cc:dd:ee:01'

2. View the ARP cache and understand the REACHABLE/STALE states — the basis for debugging 'host unreachable'

# View the full cache with state
ip neigh show

# View only the REACHABLE entries
ip neigh show nud reachable

# Delete one specific entry
sudo ip neigh del 192.168.1.10 dev eth0

Observation: # State lifecycle: REACHABLE → STALE (idle) → FAILED (ARP gets no reply)

3. Check for an IP conflict with Gratuitous ARP — important when adding a new IP or after a failover

# -D = Duplicate Address Detection mode
# Exit code 1 = conflict
arping -D -I eth0 -c 2 192.168.1.5
echo "Exit: $?"  # 0=OK, 1=conflict

Observation: # If exit is 1: another machine replied to the Gratuitous ARP → the IP is already in use

4. See the ARP path when pinging the Internet — confirm that 'the frame uses the gateway's MAC, not the destination's MAC'

# Look at the routing table — read the default via line to find the gateway
ip route

# Flush the cache, ping 8.8.8.8, see which IP ARP happens for
sudo ip neigh flush all
sudo tcpdump -i eth0 arp -n &
ping -c 1 8.8.8.8
sleep 1 && kill %1
ip neigh show  # Only the gateway IP shows up, not 8.8.8.8

Observation: # ip neigh show after pinging 8.8.8.8: only an entry for 192.168.1.1 (the gateway)

5. Detect signs of ARP spoofing on the network — a necessary skill for security and auditing

# Find 2 IPs with the same MAC address (a sign of spoofing)
ip neigh show | awk '{print $5}' | sort | uniq -d

# Scan ARP across the whole LAN and compare
sudo arp-scan --localnet 2>/dev/null | awk '/([0-9a-f]{2}:){5}/' | sort -t$'\t' -k2

# If a MAC matches 2+ IPs → investigate immediately

Observation: # Output of ip neigh: column 5 is the MAC address

Review questions

Question 1. A computer knows the destination IP 192.168.1.10. Why does it still need ARP before sending the frame?

  1. To check whether the host is still alive

  2. An Ethernet frame needs a destination MAC; you cannot put an IP in the MAC field

  3. ARP helps find the routing path

  1. To encrypt the data before sending

Answer: An Ethernet frame needs a destination MAC; you cannot put an IP in the MAC field. The Ethernet frame header has a Destination MAC field — it must be a 6-byte MAC.

There is no syntax for putting an IP there. ARP is the mandatory step to obtain the MAC from the IP before framing.

Question 2. You ping 8.8.8.8 from host 192.168.1.5. Which IP's MAC will the ARP request ask for?

  1. 8.8.8.8 — the destination IP being pinged

  2. 192.168.1.5 — the sending host's IP

  3. 192.168.1.1 — the IP of the default gateway

  1. There is no ARP because 8.8.8.8 is on the Internet

Answer: 192.168.1.1 — the IP of the default gateway. 8.8.8.8 is not in the same subnet → the kernel consults the routing table → the next hop is the default gateway 192.168.1.1.

The frame must reach the gateway first → ARP asks for the MAC of 192.168.1.1, not 8.8.8.8. The MAC of 8.8.8.8 does not exist on this LAN.

Question 3. Which Ethernet address is an ARP Request sent to?

  1. The gateway's MAC

  2. The destination IP's MAC (using the old table)

  3. FF:FF:FF:FF:FF:FF (broadcast)

  1. The multicast address 01:00:5E:...

Answer: FF:FF:FF:FF:FF:FF (broadcast). An ARP Request is a broadcast because the destination MAC is not known yet — that is exactly why it has to ask.

FF:FF:FF:FF:FF:FF is the Ethernet broadcast address, which every machine on the LAN receives and reads.

Question 4. How is an ARP Reply sent?

  1. Broadcast — so every machine updates its cache

  2. Unicast — straight back to the machine that sent the Request

  3. Multicast — to save bandwidth

  1. Sent through a router to the asker

Answer: Unicast — straight back to the machine that sent the Request. The ARP Request carries the asker's MAC in the Sender MAC field. The target reads it → sends a unicast Reply to that MAC.

There is no need to broadcast again — it saves CPU on every machine on the LAN.

Question 5. An attacker on the same LAN sends a fake ARP Reply: 'IP 192.168.1.1 has MAC=attacker_mac'. What is the consequence?

  1. None — the victim will verify by asking again

  2. The victim stores the wrong MAC in its cache → traffic to the gateway goes through the attacker (MITM)

  3. The switch detects and blocks the fake frame

  1. The router rejects frames with the wrong MAC

Answer: The victim stores the wrong MAC in its cache → traffic to the gateway goes through the attacker (MITM).

ARP has no authentication mechanism — the machine receiving the Reply trusts it and updates its cache immediately, even if it never sent a Request (gratuitous ARP).

The victim sends traffic to attacker_mac instead of the gateway → the attacker forwards it on to avoid detection, and reads/modifies the content.

Question 6. Which command shows the ARP cache on modern Linux?

  1. arp -a

  2. ip neigh show

  3. netstat -r

  1. route -n

Answer: ip neigh show. ip neigh show is the modern command (iproute2); it shows the neighbor table (ARP cache) with state (REACHABLE/STALE/FAILED). arp -a also works but is legacy (net-tools) and gives less information.

Question 7. After ip neigh flush all, pinging 192.168.1.10 succeeds. What happens with ARP?

  1. Ping uses the IP directly, so ARP is not needed

  2. ARP Request broadcast → Reply from 192.168.1.10 → the cache is populated → ICMP can be sent

  3. Ping fails because the cache is empty

  1. The kernel fills in the MAC from the routing table by itself

Answer: ARP Request broadcast → Reply from 192.168.1.10 → the cache is populated → ICMP can be sent. With an empty cache → the kernel sends an ARP Request broadcast.

192.168.1.10 replies with its MAC. The kernel stores it in the cache. Only then can the ICMP Echo Request be sent in an Ethernet frame with the correct MAC. The whole thing happens within a few ms.

Flashcards

Address Resolution Protocol — maps an IP (L3) to a MAC (L2). It solves the problem that an Ethernet frame needs a destination MAC but the app only knows the IP.

*This is the mandatory bridge between L2 and L3. Without ARP you cannot send a frame even if you know the IP — understanding this helps you debug 'host unreachable' faster. *

The Ethernet broadcast FF:FF:FF:FF:FF:FF. Because the destination MAC is not known yet — it has to ask every machine on the LAN.

*A broadcast costs the CPU of every machine on the LAN → that is why the ARP cache matters. Understanding this helps explain why a large LAN (many machines) is prone to broadcast storms. *

Unicast — straight to the MAC of the machine that sent the Request (taken from the Sender MAC field in the Request).

*An optimal design: it already has enough information to unicast, without bothering the whole LAN. Understand this point so you do not confuse it with 'ARP is always broadcast'. *

The MAC of 192.168.1.1 (the default gateway) — not 8.8.8.8. 8.8.8.8 is in a different subnet → it has to go through the gateway. *The point devs get wrong most often.

A frame can only travel within one LAN — the destination MAC is always the next hop (the gateway), not the final destination IP. Important when debugging MITM and routing. *

Typically 60s (REACHABLE) → 1 more minute (STALE) → FAILED. View with ip neigh show. Flush with ip neigh flush all. *When the cache expires → ARP again → takes time.

In production, cache flapping (the MAC changing constantly) usually signals ARP spoofing or a failover. *

The attacker sends a fake ARP Reply (without being asked first): 'IP_victim/gateway has MAC=attacker_mac'. The victim believes it → the cache is poisoned → MITM.

*ARP has no authentication — a by-design weakness of RFC 826.

Know this to understand why you need DAI on the switch and why you should not trust unfamiliar LANs (hotels, cafes). *

An ARP Request/Reply where sender IP = target IP (the host announces its own IP). Used for: (1) announcing a new MAC after a failover, (2) detecting IP conflicts, (3) VRRP/keepalived.

*Keepalived/VRRP sends a Gratuitous ARP when the VIP moves to the backup node — every machine updates its cache with the new MAC.

Without Gratuitous ARP, traffic is blackholed for ~5 minutes until the old cache expires. *

A feature on managed switches: it checks whether ARP packets are valid (against the DHCP snooping table). An untrusted port that sends a fake ARP Reply → the switch blocks it.

*DAI is an L2 defense against ARP spoofing — no host changes needed. Important in datacenter and enterprise environments. If you only have an unmanaged switch → use a VPN. *

Each ARP Request = a broadcast to 999 other machines. If many machines ARP at once → every host's CPU has to process thousands of broadcasts per second.

*This is why VLANs were invented: to split a large LAN into several small broadcast domains. /24 = 254 hosts; /22 = 1022 hosts — scaling linearly with the number of hosts. *

REACHABLE: recently used, trustworthy. STALE: not used for a while, may be outdated. FAILED: ARP failed. PERMANENT: hard-configured, never expires.

*STALE does not mean wrong — when a frame needs to be sent, the kernel probes again. FAILED = host unreachable. Debugging 'neighbor table overflow' applies when there are too many unfamiliar /24 IPs.

A router answers ARP on behalf of a host on another network, supplying the router's own MAC. The host thinks the target is on the same LAN, but in reality it goes through the router.

*Used in some VPNs and legacy networks. Downside: it hides the network boundary and is hard to debug. On Linux: net.ipv4.conf.eth0.proxy_arp=1. *

The ARP protocol