How ARP Maps IP Addresses to MAC Addresses

How ARP resolves IPv4 addresses to MAC addresses: request and reply flow, RFC 826 packet format, Linux ip neigh cache, gratuitous ARP and spoofing defence.

Jul 30, 2025 - 10:26
Nov 5, 2026 - 20:16
 0  118
TOPICDevOps BasicsPractical guide
How ARP Maps IP Addresses to MAC Addresses

ARP (Address Resolution Protocol) maps an IPv4 address to a MAC address on the local network. A host that needs to reach a local IP broadcasts an ARP request asking "who has this IP?", the owner replies with its MAC address in a unicast ARP reply, and both sides cache the mapping for a short time.

ARP sits between layer 2 and layer 3 of the OSI model: IP decides where a packet should go, but Ethernet and Wi-Fi frames are delivered by hardware address. ARP is the glue that turns one into the other. This guide follows a real lookup packet by packet, shows the ARP frame format from RFC 826, explains how the cache behaves on Linux, and covers ARP spoofing from a defender's point of view. If you need a refresher on what a hardware address is, start with Why Are MAC Addresses Considered Permanent and Unique?.

Key takeaways

  • ARP is defined in RFC 826 (1982) and only works within one broadcast domain, such as a single VLAN or subnet.
  • Requests go to the broadcast MAC ff:ff:ff:ff:ff:ff; replies are normally unicast back to the asker.
  • For a destination outside the subnet, the host ARPs for its default gateway, not for the remote IP.
  • Every host keeps an ARP cache (the neighbour table on Linux). View it with ip neigh.
  • ARP has no authentication, which makes spoofing possible. Switch features such as Dynamic ARP Inspection are the standard defence.
  • IPv6 does not use ARP. It uses Neighbor Discovery (RFC 4861) over ICMPv6.

Why IP addresses alone cannot deliver a frame

An IPv4 address is logical. It is assigned by configuration or DHCP and can move between machines. A network interface card only accepts frames addressed to its own MAC address, the broadcast address, or multicast groups it has joined. So when your laptop at 192.168.1.20 wants to send a packet to a printer at 192.168.1.50, the IP layer knows the destination, but the Ethernet driver needs a 48-bit MAC address to put in the frame header. ARP finds it.

The two addresses do different jobs:

PropertyIPv4 addressMAC address
LayerNetwork (layer 3)Data link (layer 2)
Length32 bits48 bits
Assigned byAdmin or DHCPManufacturer (can be overridden in software)
ScopeRouted end to endOnly meaningful on the local link
Changes at each router hop?NoYes, rewritten at every hop

How an ARP lookup works, step by step

Assume host A (192.168.1.20, MAC aa:aa:aa:aa:aa:aa) wants to send to host B (192.168.1.50, MAC bb:bb:bb:bb:bb:bb) on the same /24.

  1. Is the target local? A compares B's address with its own address and subnet mask. Both are in 192.168.1.0/24, so B is on the same link. (Our guide on calculating subnets shows how that comparison works.)
  2. Check the cache. A looks in its ARP cache for 192.168.1.50. If a valid entry exists, it builds the frame straight away and no ARP traffic is sent.
  3. Broadcast a request. On a cache miss, A queues the IP packet and sends an ARP request in an Ethernet frame to ff:ff:ff:ff:ff:ff. The request says, in effect, "Who has 192.168.1.50? Tell 192.168.1.20 at aa:aa:aa:aa:aa:aa."
  4. Every host on the segment receives it. Switches flood broadcasts out of every port in the VLAN. Hosts whose IP does not match drop the request.
  5. The owner replies. B recognises its own IP. It adds A's mapping to its own cache (RFC 826 lets the target learn the sender's details from the request) and sends an ARP reply directly to aa:aa:aa:aa:aa:aa with "192.168.1.50 is at bb:bb:bb:bb:bb:bb."
  6. A caches the answer and sends the data. A stores the mapping, then releases the queued packet in a frame addressed to B's MAC.

The whole exchange is two small frames and usually completes in well under a millisecond on a wired LAN.

What changes when the destination is remote

If A wants to reach 8.8.8.8, the subnet check fails. A does not ARP for 8.8.8.8, because that host is not on the local link. It looks up its routing table, finds the default gateway (say 192.168.1.1), and ARPs for the gateway's MAC instead. The frame goes to the router's MAC while the IP header still says 8.8.8.8. The router strips the frame, makes its routing decision, and uses ARP again on its next-hop interface. This is why MAC addresses change at every hop while IP addresses stay the same. The TCP/IP model guide traces this hop-by-hop behaviour in more examples.

Inside the ARP packet

ARP runs directly over Ethernet with EtherType 0x0806. It does not use IP at all. For IPv4 over Ethernet the ARP payload is 28 bytes:

FieldSizeTypical value
Hardware type (HTYPE)2 bytes1 = Ethernet
Protocol type (PTYPE)2 bytes0x0800 = IPv4
Hardware address length (HLEN)1 byte6
Protocol address length (PLEN)1 byte4
Operation (OPER)2 bytes1 = request, 2 = reply
Sender hardware address (SHA)6 bytesSender's MAC
Sender protocol address (SPA)4 bytesSender's IPv4
Target hardware address (THA)6 bytesZeros in a request; asker's MAC in a reply
Target protocol address (TPA)4 bytesIP being resolved

The hardware and protocol type fields are why RFC 826 calls ARP generic: the same format can resolve other protocol addresses over other link types. In practice almost all ARP traffic you will see is IPv4 over Ethernet or Wi-Fi.

You can watch the exchange with tcpdump:

sudo tcpdump -n -e -i eth0 arp
# Example output (abbreviated):
# aa:aa:aa:aa:aa:aa > ff:ff:ff:ff:ff:ff, ARP, Request who-has 192.168.1.50 tell 192.168.1.20
# bb:bb:bb:bb:bb:bb > aa:aa:aa:aa:aa:aa, ARP, Reply 192.168.1.50 is-at bb:bb:bb:bb:bb:bb

The ARP cache

Broadcasting for every packet would waste bandwidth and CPU on every host, so each system caches mappings. Entries age out so that a changed mapping (a replaced NIC, a moved IP) is eventually corrected.

Viewing and managing the cache on Linux

Linux calls it the neighbour table and manages it with the ip command from iproute2. The older arp command from net-tools still works where installed but is deprecated on most distributions.

# Show the table
ip neigh show
# 192.168.1.1 dev eth0 lladdr 11:22:33:44:55:66 REACHABLE
# 192.168.1.50 dev eth0 lladdr bb:bb:bb:bb:bb:bb STALE

# Remove one entry (forces a fresh lookup next time)
sudo ip neigh del 192.168.1.50 dev eth0

# Flush all entries on an interface
sudo ip neigh flush dev eth0

# Add a permanent (static) entry
sudo ip neigh add 192.168.1.10 lladdr 00:11:22:33:44:55 dev eth0 nud permanent

Linux tracks each entry with a state from its neighbour unreachability detection (NUD) logic:

StateMeaning
REACHABLERecently confirmed; used without checking
STALEStill usable, but not confirmed recently. Linux reconfirms it the next time traffic is sent
DELAY / PROBEWaiting for confirmation, then sending unicast probes
FAILEDNo answer to probes; packets to this address are dropped
INCOMPLETERequest sent, no reply yet
PERMANENTStatic entry added by an administrator

Timers are controlled by sysctl settings under /proc/sys/net/ipv4/neigh/, such as base_reachable_time_ms and gc_stale_time. The defaults suit most networks. Large container hosts or Kubernetes nodes with many neighbours sometimes need higher gc_thresh1/2/3 values to avoid "neighbour table overflow" messages in the kernel log.

Windows and macOS

On Windows, arp -a lists the cache and netsh interface ip show neighbors gives more detail. On macOS, arp -a works the same way.

Special kinds of ARP

Gratuitous ARP

A gratuitous ARP is an ARP packet a host sends about its own address without being asked. Hosts send one when an interface comes up, and failover systems such as keepalived (VRRP) send them when a virtual IP moves to a new node. Neighbours that already have the IP in their cache update the MAC, so traffic switches to the new owner within moments instead of waiting for entries to expire.

ARP probes and address conflict detection

RFC 5227 defines how a host checks whether an IPv4 address is already in use before claiming it. It sends ARP probes with a sender IP of 0.0.0.0 asking for the address. If anyone answers, there is a conflict. The arping utility can run the same check by hand:

sudo arping -D -I eth0 -c 2 192.168.1.50   # duplicate address detection
echo $?                                    # 0 = no reply (free), 1 = address in use

What happens when two hosts do end up with the same IP is covered in What Happens When Two Devices Share the Same IP Address?.

Proxy ARP

With proxy ARP (RFC 1027), a router answers ARP requests on behalf of hosts on another network, so hosts without correct routing can still reach them. It is rarely a deliberate design today and can hide misconfigured subnet masks, so most networks leave it off. On Linux it is controlled per interface by net.ipv4.conf.<iface>.proxy_arp.

Reverse ARP

RARP (RFC 903) went the other way, from MAC to IP, so diskless machines could learn their address at boot. BOOTP and then DHCP replaced it long ago.

ARP spoofing: the risk and how to defend against it

ARP has no authentication. Hosts accept replies, and often gratuitous ARPs, without checking who sent them. An attacker on the same segment can therefore send forged replies that claim the gateway's IP maps to the attacker's MAC. Victims then send their traffic through the attacker, which allows interception or disruption. This is known as ARP spoofing or ARP cache poisoning. It only works from inside the broadcast domain, which is one reason segmentation matters.

Defences, from most to least effective in typical enterprise networks:

  • Dynamic ARP Inspection (DAI) on managed switches drops ARP packets whose IP-to-MAC binding does not match a trusted table, usually built from DHCP snooping. Cisco and other vendors document it in their switch configuration guides.
  • DHCP snooping records which IP was leased to which MAC on which port. It is the data source DAI depends on.
  • Segmentation with VLANs and smaller subnets limits who can reach whom at layer 2. See How Subnetting Improves Network Efficiency and Security.
  • Encryption in transit (TLS, SSH, IPsec) means intercepted traffic cannot be read or silently altered, even if ARP is poisoned.
  • Static entries for a few critical addresses, such as the gateway on a sensitive server. They do not scale and must be updated by hand when hardware changes.
  • Monitoring: tools such as arpwatch log new and changed IP-to-MAC pairings. A sudden change in the gateway's MAC address is worth an alert.

In cloud VPCs the provider's virtual network handles address resolution and does not forward forged ARP between instances in the usual way, so classic spoofing is mostly a concern for on-premises LANs, Wi-Fi and lab networks. For broader hardening of network services, read Securing TCP and UDP Services: Best Practices.

ARP versus IPv6 Neighbor Discovery

AspectARP (IPv4)Neighbor Discovery (IPv6)
StandardRFC 826RFC 4861
TransportIts own EtherType, 0x0806ICMPv6 messages inside IPv6
Request sent toBroadcastSolicited-node multicast address
MessagesRequest, replyNeighbor Solicitation, Neighbor Advertisement, plus router messages
Security extensionNone in the protocolSEND (RFC 3971), rarely deployed; RA Guard on switches is more common

On Linux both appear in the same table: ip -6 neigh shows IPv6 neighbours.

Troubleshooting with ARP

When a host cannot reach a neighbour on the same subnet, the neighbour table often tells you why:

  • Entry is INCOMPLETE or FAILED: the target is not answering ARP. It may be down, on another VLAN, or blocked by a firewall that filters ARP (rare) or a port security feature.
  • Entry shows an unexpected MAC: another device may have the same IP, or a failover moved the address. Compare with the target's ip link output.
  • Gateway MAC keeps changing: possible duplicate gateway addresses, a flapping VRRP pair, or spoofing. Capture with tcpdump and check switch logs.
  • Works after flushing the cache: a stale entry survived a hardware change. Check whether the new device sent a gratuitous ARP when it came up.

These checks come up in Linux and DevOps interviews as well as in production. Networking basics like ARP, routing and subnetting are part of our Linux administration course, taught in Kharadi, Pune and live online.

Frequently asked questions

What is ARP in simple terms?

ARP is how a device on a local network finds the MAC address that belongs to an IPv4 address. It broadcasts a question asking who has the IP, and the owner answers with its MAC address.

Is ARP a layer 2 or layer 3 protocol?

ARP is carried directly in layer 2 frames with its own EtherType, but its job is to serve layer 3 by resolving IPv4 addresses. Most textbooks place it between the two layers.

Why is an ARP request broadcast but the reply unicast?

The asker does not know the target's MAC yet, so it must broadcast to reach every host. The target learns the asker's MAC from the request, so it can reply directly.

How long do ARP entries stay in the cache?

It depends on the operating system. Linux marks entries STALE after a reachable time of tens of seconds and reconfirms them when traffic is sent, controlled by sysctl values under /proc/sys/net/ipv4/neigh. Windows and network devices use their own timers.

What is a gratuitous ARP?

It is an unsolicited ARP announcement a host sends about its own IP and MAC. Systems send it at interface startup and during failover so neighbours update their caches quickly.

Does ARP cross routers?

No. ARP works only within one broadcast domain. For remote destinations a host resolves its default gateway's MAC, and each router performs its own ARP on the next network.

Does IPv6 use ARP?

No. IPv6 uses Neighbor Discovery, defined in RFC 4861, which sends ICMPv6 Neighbor Solicitation and Advertisement messages to multicast addresses instead of broadcasts.

How can I protect a network from ARP spoofing?

Enable DHCP snooping and Dynamic ARP Inspection on managed switches, segment networks with VLANs, encrypt traffic with TLS or SSH, and monitor IP-to-MAC changes with a tool such as arpwatch.

Official references

Interested in learning more?Get a callback from our training advisors.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.