Course contents

Unit 6: ARP and Local CommunicationLesson 6.1 (1 of 3 in this unit)47 of 104 in the Network Fundamentals course

ARP Fundamentals

Your PC knows the next device's IPv4 address, but how does it learn the Ethernet address needed to send a frame? Let's follow one request, one reply and the cache entry they leave behind.

Beginner · 15 min read · Before this: MAC addresses, What is an IP address?, The default gateway

You'll learn to predict when a host sends an ARP request, what the request and reply contain, and what happens when nobody answers.

Technical definition

ARP (Address Resolution Protocol) is the protocol an IPv4 device uses to find the MAC (hardware) address that belongs to an IPv4 address on its local network. It asks with a broadcast request and gets the answer in a unicast reply.

The gap ARP fills

To send an IP packet over Ethernet, a host must put it in a frame, and a frame needs a destination MAC address. The host knows the destination's IP address (you typed it, or DNS provided it), but not its MAC address. ARP (Address Resolution Protocol) asks the local network: "Who has this IP address? Tell me your MAC address."

Two addresses, set independently

A host on an Ethernet or Wi-Fi network, such as a PC, a phone or a router interface, has two addresses that do different jobs. (Not every network device needs both: an unmanaged switch forwards frames without any IP address of its own.)

  • The IP address is a logical address used end to end. Applications and people use it.
  • The MAC address is a hardware address that only has meaning on one local link. Switches and network cards use it.

Learn more: What Is an IP Address?MAC Addresses

Nothing in the IP address tells you the MAC address. They are set independently: the IP address by DHCP or an administrator, and the MAC address by the manufacturer (or randomly by the operating system, on many phones and laptops). So something has to look up the MAC address at the moment it is needed. On IPv4 networks, that is ARP.

ARP stays on the local subnet

Before following the exchange, separate the two jobs. The route lookup chooses the next hop, meaning the next device that should receive the packet on this link. ARP then finds that device's MAC address. For local PC-B, the next hop is PC-B itself. For a remote server reached through the default route, the next hop is the nearby router. A useful ARP answer cannot repair a wrong route.

An ARP request is its own Ethernet payload, not an IPv4 packet sent to a special TCP or UDP port. In the header diagram below, EtherType 0x0806 tells the receiver to interpret the payload as ARP. The sender and target IP fields inside that payload describe the mapping being requested; they are not an IP header.

ARP works on the local subnet only. Strictly, an ARP broadcast reaches the whole Layer 2 broadcast domain (the VLAN), not the IP subnet. Usually one VLAN carries one subnet, so the two are the same; if two subnets share a VLAN, hosts in both receive the broadcast, and only the owner of the target address answers. Its messages are carried directly in an Ethernet frame with EtherType 0x0806 (normal IPv4 traffic uses 0x0800). There is no IP header in an ARP message, so a router has no destination IP address to route it with, and it does not forward ARP messages to other networks.

The broadcast request and unicast reply below are the ordinary case. There are variants: a gratuitous ARP announces a device's own address (used after an address change and by gateway redundancy protocols), proxy ARP lets a router answer for another host, and many operating systems send a unicast ARP request to check that a cached entry is still valid.

Request, reply, cache and next hop

ARP Request

“Who has 192.168.10.20? Tell 192.168.10.10.” It is sent as a broadcast, because the sender doesn't know the target's MAC address yet. Every device in the same broadcast domain (VLAN) receives it.

ARP Reply

“192.168.10.20 is at 02:00:00:00:00:bb.” It is sent as a unicast directly back to the sender of the request, whose MAC address was in the request.

ARP cache

A small table in every host and router that remembers IP address → MAC address answers for a while, so ARP isn't needed for every packet.

Next-hop IP

The IP address that ARP resolves: the destination itself if it is on the local subnet, or the default gateway if it is remote.

The addresses used in this lesson

Diagram
The addresses used in this lesson
The addresses used in this lesson
DeviceIP addressMAC address
PC-A192.168.10.10/2402:00:00:00:00:aa
PC-B192.168.10.20/2402:00:00:00:00:bb
Default gateway (router R1)192.168.10.1/2402:00:00:00:00:01
Read each row across: the left box names the item, the others describe it.

Three outcomes when PC-A sends to PC-B

PC-A wants to send a packet to PC-B (192.168.10.20). What happens depends on what is already in its ARP cache, and on whether PC-B answers. Pick a case:

Diagram
ARP request and reply on 192.168.10.0/24
ARP request and reply on 192.168.10.0/24
PC-A sends to 192.168.10.20 and:
SwitchPC-A192.168.10.10 · …:aaPC-B192.168.10.20 · …:bbGateway R1192.168.10.1 · …:01Frame02:00:00:00:00:aa → ff:ff:ff:ff:ff:ffPacketno IP packetARP request: who has 192.168.10.20? Tell 192.168.10.10

Device key: PC-A (laptop) · PC-B (computer) · Gateway R1 (router)

Lines show the example’s network connections. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.

Reading the addresses

IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.

An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.

MAC addresses identify link-layer interfaces or destination groups. They are not IP addresses or website URLs.

  • PC-A: 192.168.10.10 · …:aa
  • PC-B: 192.168.10.20 · …:bb
  • Gateway R1: 192.168.10.1 · …:01

Frame 02:00:00:00:00:aa to ff:ff:ff:ff:ff:ff.

Tip: click or tap a device to see its details.

  1. 1. Request (broadcast): PC-A doesn't know PC-B's MAC address, so it broadcasts an ARP request. The packet for PC-B waits in a queue.
  2. 2. Everyone receives it: The switch floods it out of every other port. R1 sees the target IP is not its own and ignores it.
  3. 3. Reply (unicast): Only PC-B answers, straight to PC-A's MAC address. PC-B also caches PC-A's addresses from the request.
  4. 4. Cached and sent: PC-A stores the answer and sends the waiting packet to PC-B's MAC address.
For this ordinary exchange, a broadcast request finds the next hop and a unicast reply supplies its MAC. A usable cached mapping avoids this initial lookup; validation and announcements can also generate ARP traffic.

Inside one ARP exchange

Diagram
Process, step by step
1. PC-A wants to send to 192.168.10.20
Its subnet mask shows that .20 is local, so the next hop is .20 itself. For a remote host, the next hop would be the default gateway.
2. Check the ARP cache
If there is an entry for 192.168.10.20, use it and skip to step 6. If not, continue.
3. Broadcast an ARP request
Destination MAC address ff:ff:ff:ff:ff:ff. Meanwhile, the packet waiting to be sent is held in a queue.
4. Every device checks the target IP
Devices that don't own the target IP address ignore it. PC-B sees “that's me” and caches PC-A's IP and MAC addresses from the request.
5. PC-B sends a unicast ARP reply
Directly to 02:00:00:00:00:aa, saying that 192.168.10.20 is at 02:00:00:00:00:bb.
6. PC-A caches the answer and sends the frame
Destination MAC address 02:00:00:00:00:bb, destination IP address 192.168.10.20.

Read in arrow direction. Labels describe each stage or hop; connectors show the sequence, not a complete physical cabling plan or time to scale.

What happens inside PC-A and PC-B during one ARP exchange.

Inside an ARP message

An ARP message for IPv4 over Ethernet is 28 bytes long. It is padded to the Ethernet minimum frame size, so on the wire it fills a 64-byte frame.

Hardware type16 bits1 = Ethernet
Protocol type16 bits0x0800 = IPv4
HW length8 bits6 (bytes)
Proto length8 bits4 (bytes)
Operation16 bits1 request · 2 reply
Sender MAC address48 bits (continues)
Sender MAC (end)
Sender IP address32 bits (continues)
Sender IP (end)
Target MAC address48 bits (continues)
Target MAC (end)
Target IP address32 bitsthe address being asked about

Read each row from left to right. The ruler gives bit positions 0–31 within that row; field sizes are labelled in bits or bytes.

The ARP message for IPv4 over Ethernet (28 bytes). The 6-byte MAC and 4-byte IP fields don't line up with 32-bit rows, so they wrap.
Diagram
Inside an ARP message
Inside an ARP message
FieldIn the requestIn the reply
Operation1 (request)2 (reply)
Sender MAC02:00:00:00:00:aa (PC-A)02:00:00:00:00:bb (PC-B)
Sender IP192.168.10.10192.168.10.20
Target MAC00:00:00:00:00:00 (unknown)02:00:00:00:00:aa (PC-A)
Target IP192.168.10.20192.168.10.10
Read each row across: the left box names the item, the others describe it.

The frames that carry them

ARP Request frame

Broadcast

Layer 2 · Ethernet header (this hop)
Destination MAC
ff:ff:ff:ff:ff:ff
everyone
Source MAC
02:00:00:00:00:aa
PC-A
EtherType
0x0806
ARP (not IPv4)
Payload
ARP message · op 1 · sender 192.168.10.10 / …:aa · target 192.168.10.20 / 00:00:00:00:00:00

ARP Reply frame

Unicast

Layer 2 · Ethernet header (this hop)
Destination MAC
02:00:00:00:00:aa
PC-A only
Source MAC
02:00:00:00:00:bb
PC-B
EtherType
0x0806
ARP
Payload
ARP message · op 2 · sender 192.168.10.20 / …:bb · target 192.168.10.10 / …:aa

Notice that there is no IP header in either frame: the IP addresses are fields inside the ARP message. IPv6 doesn't use ARP at all. It uses Neighbor Discovery instead.

Why the gateway is the busiest ARP entry

A host only sends ARP requests for addresses on its own subnet. For any other destination, it sends an ARP request for its default gateway and sends the frame to the gateway's MAC address. The packet inside keeps the remote destination IP address. This is why the most used entry in most PCs' ARP caches is the router. The topic is important enough to have its own lesson.

Learn more: ARP for Local and Remote Destinations

The ARP cache: how long answers last

Answers are cached so that ARP isn't needed for every packet. Entries expire after seconds to minutes on most PCs, and after 4 hours by default on Cisco routers. If a device's MAC address changes (for example, after a network card is replaced or a failover), stale entries can send traffic to the old MAC address for a while.

Before PC-A has talked to anyone, its cache is nearly empty:

Example output from a Windows PC (PC-A), written for this lesson
C:\> arp -a
Interface: 192.168.10.10 --- 0xb
  Internet Address      Physical Address      Type
  192.168.10.255        ff-ff-ff-ff-ff-ff     static
  224.0.0.22            01-00-5e-00-00-16     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static
What to look for: there are only static entries for broadcast and multicast addresses, which Windows adds by itself. No other device is known yet.

After PC-A has talked to PC-B and to the internet:

Example output from a Windows PC (PC-A), written for this lesson
C:\> arp -a
Interface: 192.168.10.10 --- 0xb
  Internet Address      Physical Address      Type
  192.168.10.1          02-00-00-00-00-01     dynamic
  192.168.10.20         02-00-00-00-00-bb     dynamic
  192.168.10.255        ff-ff-ff-ff-ff-ff     static
  224.0.0.22            01-00-5e-00-00-16     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static
What to look for: the two new dynamic entries, for the default gateway (192.168.10.1) and PC-B. They were learned with ARP and will expire. Windows writes MAC addresses with dashes.
Example output from a Linux PC, written for this lesson
$ ip neigh
192.168.10.1 dev eth0 lladdr 02:00:00:00:00:01 REACHABLE
192.168.10.20 dev eth0 lladdr 02:00:00:00:00:bb STALE
Linux calls the ARP cache the neighbour table. What to look for: REACHABLE means the entry was confirmed recently. STALE means it can still be used, but Linux will confirm it again the next time it sends traffic to that address. On older Linux systems and on macOS, use arp -a.
Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip arp
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  192.168.10.1            -   0200.0000.0001  ARPA   GigabitEthernet0/0
Internet  192.168.10.10          12   0200.0000.00aa  ARPA   GigabitEthernet0/0
Internet  192.168.10.20           3   0200.0000.00bb  ARPA   GigabitEthernet0/0
What to look for: a dash in the Age column marks the router's own address. A number shows how many minutes ago the entry was learned or last refreshed. A router keeps ARP entries for every subnet it is connected to.
arp -d *

Clear the ARP cache on Windows (run as administrator). On Linux, use sudo ip neigh flush all. On a Cisco router, use clear arp-cache.

What happens when ARP fails

SituationWhat you seeWhy
The target is off or unplugged, or the IP address is wrongPing: "Reply from 192.168.10.10: Destination host unreachable"; Linux neighbour state FAILED or INCOMPLETENobody answered the ARP request, so no frame can be built. The message comes from your own PC, not from the target.
Two devices with the same IP addressConnections that work and then drop; an "IP address conflict" warningBoth devices answer ARP requests, and caches switch between the two MAC addresses.
Stale entry after a device is replacedThe new device is unreachable until old entries are refreshed (seconds on PCs, up to hours on routers)Others still send to the old MAC until the entry expires. Clearing the cache fixes it.
Wrong default gateway addressLocal destinations work; remote ones failThe PC sends ARP requests for an address that no router uses (see The Default Gateway).

ARP has no built-in security: any device can answer, and hosts believe the answer. Attackers abuse this with ARP spoofing. The ARP Security lesson (CCNA track) explains how networks defend against it. Special ARP messages, such as gratuitous ARP, have their own lesson.

Learn more: ARP SecurityGratuitous ARP, Probes and Proxy ARP

Four checks for an ARP problem

  1. Ping the address you can't reach. This triggers an ARP request if there is no cache entry.
  2. Look at the ARP cache with arp -a or ip neigh. Is there an entry for the next hop (the host itself, or the default gateway for remote traffic)?
  3. No entry, or FAILED: the target didn't answer. Check that it is powered on, connected, in the same VLAN, and has the IP address you expect.
  4. An entry with an unexpected MAC address: there is a duplicate IP address or an old cache entry. Compare it with the MAC address on the device itself (ipconfig /all), then clear the cache.

When a duplicate IP address is suspected, the unexpected MAC address is the best lead. Look it up in the switch's MAC address table and it points to the port where the second device is plugged in.

Exercise: the replaced printer

The office printer at 192.168.10.30 was replaced this morning. The new printer kept the same IP address. Now PC-A can't print, although PC-B, which was switched off overnight, prints fine. The sticker on the new printer says its MAC address is 02-00-00-00-00-3b. On PC-A you run:

Example output from a Windows PC (PC-A), written for this lesson
C:\> arp -a
Interface: 192.168.10.10 --- 0xb
  Internet Address      Physical Address      Type
  192.168.10.1          02-00-00-00-00-01     dynamic
  192.168.10.30         02-00-00-00-00-30     dynamic
Compare the entry for 192.168.10.30 with the new printer's MAC address, then answer the first question below.

ARP misconceptions to drop

  • Thinking a PC sends ARP requests for remote IP addresses, such as a web server on the internet. The remote server can't receive the broadcast, so the PC sends an ARP request for its default gateway instead.
  • Thinking the reply is a broadcast. Only the request is a broadcast. The reply is a unicast, because the target already knows the sender's MAC address from the request.
  • Confusing the ARP cache with a switch's MAC address table. The ARP cache on hosts and routers maps IP address → MAC address; a switch's table maps MAC address → port (see How a Switch Learns MAC Addresses).
  • Expecting ARP to cross a router. ARP requests are broadcasts, and routers don't forward ARP broadcasts, so they stay on their own subnet.
What ARP does, in five points
  • ARP finds the MAC address that belongs to an IPv4 address on the local subnet.
  • The request is a broadcast to ff:ff:ff:ff:ff:ff; the reply is a unicast back to the sender.
  • ARP is carried directly in Ethernet frames (EtherType 0x0806), with operation, sender MAC/IP and target MAC/IP fields.
  • Answers are kept in the ARP cache. View it with arp -a or ip neigh.
  • Hosts send ARP requests for local destinations directly, and for the default gateway for everything else.

Test yourself on ARP

Predict · scenario 1

In the troubleshooting exercise above, why can't PC-A print, and what fixes it fastest?

Predict · scenario 2

PC-A (192.168.10.10/24) wants to reach a server at 203.0.113.20. Whose MAC address does it ask for with ARP?

Predict · scenario 3

You capture the traffic while PC-A resolves PC-B's MAC address. How are the ARP request and reply delivered?

Predict · scenario 4

In PC-A's ARP request for 192.168.10.20, what is in the Target MAC field?

Predict · scenario 5

PC-A pings 192.168.10.30, which is switched off. What does Windows show?

FAQ

Is ARP a Layer 2 or a Layer 3 protocol?
It sits between the two. ARP messages travel directly inside Ethernet frames (EtherType 0x0806), not inside IP packets, but their job is to link Layer 3 IP addresses to Layer 2 MAC addresses. Many people call it a Layer 2 protocol, and some call it Layer 2.5.
Does ARP work across routers?
No. ARP requests are broadcasts, and routers don't forward ARP broadcasts. A host only sends ARP requests for addresses on its own subnet: the destination itself, or the default gateway for anything remote. (With proxy ARP, a router can answer on behalf of a remote host, but the request itself still stays on the local subnet.)
How long do ARP cache entries last?
It depends on the system. Windows and Linux treat an entry as confirmed for somewhere between about 15 seconds and a few minutes, then check it again before relying on it. Cisco routers keep entries for 4 hours by default.
Does IPv6 use ARP?
No. IPv6 uses Neighbor Discovery (part of ICMPv6) instead. Its Neighbor Solicitation and Neighbor Advertisement messages do the same job as the ARP request and reply, but the solicitation is sent to a multicast address instead of a broadcast.