IP addresses identify devices across networks, but frames on a LAN need MAC addresses. ARP connects the two.
The Need for ARP
When a host wants to send an IP packet to another host on the same network, or to its default gateway, it must put the destination's MAC address in the Ethernet frame. The Address Resolution Protocol (ARP), defined in RFC 826, finds the MAC address that matches a given IPv4 address. (IPv6 uses the Neighbor Discovery Protocol instead.)
Definition: Address Resolution Protocol. A protocol that finds the MAC address corresponding to a known IPv4 address on the local network by broadcasting a request and receiving a unicast reply.
ARP Operation
- The host checks its ARP cache (table) for the IP address. 2. If it is not found, it broadcasts an ARP request to FF:FF:FF:FF:FF:FF: "Who has 192.168.1.20? Tell 192.168.1.10." 3. Every host on the LAN receives it, but only the owner of 192.168.1.20 replies, with a unicast ARP reply containing its MAC address. 4. The sender stores the mapping in its cache and sends the frame. The receiver also learns the sender's mapping from the request. Cache entries expire after a few minutes, so that changes are noticed. A gratuitous ARP is an unrequested announcement of a host's own mapping, sent when it starts up or changes its address. Reverse ARP (RARP), now replaced by DHCP, found an IP address from a MAC address. Proxy ARP lets a router answer on behalf of hosts on another network.
The ARP Table
The ARP table lists IP addresses, their MAC addresses and whether each entry is dynamic (learned) or static (entered by an administrator). It can be seen with the command arp -a on Windows and Linux, or ip neigh on Linux.
ARP Spoofing and Security
ARP has no authentication: a host accepts replies, even ones it did not ask for. In ARP spoofing (ARP poisoning), an attacker sends forged ARP replies that link its own MAC address with the IP address of another host, often the default gateway. Victims then send their traffic to the attacker, who can read or change it (a man-in-the-middle attack), block it (denial of service), or hijack sessions. Defences include static ARP entries for critical devices such as the gateway, Dynamic ARP Inspection (DAI) on managed switches, which checks ARP packets against trusted DHCP snooping records, port security, intrusion detection tools that watch for changing mappings, network segmentation with VLANs, and encryption (HTTPS, SSH, VPNs), which keeps intercepted data unreadable.
Table 2.7: ARP message types
| Message | Sent to | Purpose |
|---|---|---|
| ARP request | Broadcast | Ask for the MAC of an IP |
| ARP reply | Unicast | Give the MAC address |
| Gratuitous ARP | Broadcast | Announce one's own mapping |
| Forged reply | Victim | ARP spoofing attack |
Example 2.7: Detecting ARP spoofing
Problem: A PC's ARP table shows the gateway 192.168.1.1 at 00:1A:2B:3C:4D:5E, and also host 192.168.1.50 at 00:1A:2B:3C:4D:5E. What does this suggest, and what should be done?
Solution:
- Two different IP addresses map to the same MAC address.
- Since the gateway should have its own unique MAC, this suggests that 192.168.1.50 is claiming to be the gateway: ARP spoofing.
- Set a static ARP entry for the gateway, enable Dynamic ARP Inspection on the switch, and investigate the device at 192.168.1.50.
Result: It is a likely ARP spoofing attack; protect the gateway mapping and trace the attacker.
arp_table = {"192.168.1.1": "00:1a:2b:3c:4d:5e",
"192.168.1.20": "00:aa:bb:cc:dd:01",
"192.168.1.50": "00:1a:2b:3c:4d:5e"}
seen = {}
for ip, mac in arp_table.items():
seen.setdefault(mac, []).append(ip)
for mac, ips in seen.items():
flag = " <-- possible spoofing" if len(ips) > 1 else ""
print(f"{mac}: {', '.join(ips)}{flag}")
Output
00:1a:2b:3c:4d:5e: 192.168.1.1, 192.168.1.50 <-- possible spoofing
00:aa:bb:cc:dd:01: 192.168.1.20
Common mistakes
- Thinking ARP works across routers. It works only within one LAN.
- Sending the ARP reply as a broadcast. It is a unicast.
- Assuming ARP replies are verified. ARP has no authentication.
Key takeaways
- ARP maps IPv4 addresses to MAC addresses on a LAN.
- Requests are broadcast; replies are unicast; entries are cached.
- ARP spoofing links an attacker's MAC with another IP for man-in-the-middle attacks.
- Defences: static entries, Dynamic ARP Inspection, port security and encryption.
Practice questions
- What does ARP do?
- Which command shows the ARP table?
- What is ARP spoofing?
Answers to the practice questions
- It finds the MAC address for a given IPv4 address on the local network.
- arp -a.
- Sending forged ARP replies so that traffic for another IP address goes to the attacker's MAC address.
Sources
- Official BCA syllabus Computer Networks, course code 26BCA404DS02, Unit II
