Finding a neighbor with ARP
On this page
Laptop has decided phone is local. A frame needs phone’s MAC address, but laptop knows only its IP address. You will follow the question that supplies the missing address, then see why the next message needs no question.
- Settings: read and interpreted; their automatic source remains open.
- Finding a name: still open, for How DNS Finds Services.
- Own network or router: answered in Subnetting Foundations.
- Delivery on the cable: frames and switches answered; finding the address comes here.
- Crossing and returning: the other focus of Reaching Another Device.
- Finding programs: still open, for TCP, UDP, and Ports.
- Application words and privacy: still open, for Everyday Application Traffic.
Before you start
Section titled “Before you start”Finish Practice: Subnetting Foundations. Keep the lab up, modes off. If it has changes, leave machine shells and run netlab reset at the VM prompt. Enter laptop with netlab shell laptop. Keep all experiments inside this lab.
Start without a remembered address
Section titled “Start without a remembered address”Run sudo ip neigh flush dev eth0. Here flush removes remembered neighbors on the interface selected by dev eth0. It changes no interface address. Type your Ubuntu password when sudo asks; typing remains hidden. Then run ip neigh to read the table.
A neighbor table remembers which local IP address belongs to which MAC address. The first read below prints nothing. An older lab session may already have entries, which is why you clear them before comparing.
learner@laptop:~$ sudo ip neigh flush dev eth0[sudo] password for learner: learner@laptop:~$ ip neighlearner@laptop:~$ ping -c 1 10.77.10.11PING 10.77.10.11 (10.77.10.11) 56(84) bytes of data.
64 bytes from 10.77.10.11: icmp_seq=1 ttl=64 time=0.130 ms
--- 10.77.10.11 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.130/0.130/0.130/0.000 mslearner@laptop:~$ ip neigh10.77.10.11 dev eth0 lladdr 02:77:10:00:00:11 REACHABLE learner@laptop:~$ ping -c 1 10.77.10.11PING 10.77.10.11 (10.77.10.11) 56(84) bytes of data.
64 bytes from 10.77.10.11: icmp_seq=1 ttl=64 time=0.072 ms
--- 10.77.10.11 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.072/0.072/0.072/0.000 mslearner@laptop:~$ Steps (16)
- Type
sudo ip neigh flush dev eth0 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Type
ip neigh - Press Enter
- Type
ping -c 1 10.77.10.11 - Press Enter
- Output:
PING 10.77.10.11 (10.77.10.11) 56(84) bytes of data. 64 bytes from 10.77.10.11: icmp_seq=1 ttl=64 time=0.130 ms --- 10.77.10.11 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.130/0.130/0.130/0.000 ms - Type
ip neigh - Press Enter
- Output:
10.77.10.11 dev eth0 lladdr 02:77:10:00:00:11 REACHABLE - Type
ping -c 1 10.77.10.11 - Press Enter
- Output:
PING 10.77.10.11 (10.77.10.11) 56(84) bytes of data. 64 bytes from 10.77.10.11: icmp_seq=1 ttl=64 time=0.072 ms --- 10.77.10.11 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.072/0.072/0.072/0.000 ms
Ask the local network
Section titled “Ask the local network”ARP, the Address Resolution Protocol, finds the link address for an IPv4 neighbor. An ARP request asks which interface has a particular IP address. The first captured frame asks for 10.77.10.11, telling receivers that laptop is 10.77.10.10.
The destination ff:ff:ff:ff:ff:ff is the broadcast MAC address. Phone and router can receive the question. Router does not carry it onto the site network. ARP stays inside this broadcast domain.
Predict: the request is a broadcast. Is the reply a broadcast too?
A question, an answer, then delivery
- laptop
- phone
- router
- Ask everyone: laptop to phone and router
- Phone answers: phone to laptop
- Ping request: laptop to phone
- Ping reply: phone to laptop
In the capture4 messages at laptop:eth0
- 1. Ask everyone
14:40:59.679971 02:77:10:00:00:10 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.77.10.11 tell 10.77.10.10, length 28 - 2. Phone answers
14:40:59.680049 02:77:10:00:00:11 > 02:77:10:00:00:10, ethertype ARP (0x0806), length 42: Reply 10.77.10.11 is-at 02:77:10:00:00:11, length 28 - 3. Ping request
14:40:59.680051 02:77:10:00:00:10 > 02:77:10:00:00:11, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.10.11: ICMP echo request, id 161, seq 1, length 64 - 4. Ping reply
14:40:59.680067 02:77:10:00:00:11 > 02:77:10:00:00:10, ethertype IPv4 (0x0800), length 98: 10.77.10.11 > 10.77.10.10: ICMP echo reply, id 161, seq 1, length 64
ping -c 1 10.77.10.11, on Ubuntu 24.04.5 LTS, netlab 1.0, tcpdump 4.99.4. The values are the capture's. The captured local exchange asks everyone, receives one answer, then carries the ping request and reply. The switches are omitted from this model.Steps (4)
- Ask everyone. laptop to phone and router. Laptop asks its local broadcast domain which interface has phone’s IP address.
14:40:59.679971 02:77:10:00:00:10 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.77.10.11 tell 10.77.10.10, length 28 - Phone answers. phone to laptop. Phone answers laptop directly. The reply supplies the association to remember.
14:40:59.680049 02:77:10:00:00:11 > 02:77:10:00:00:10, ethertype ARP (0x0806), length 42: Reply 10.77.10.11 is-at 02:77:10:00:00:11, length 28 - Ping request. laptop to phone. Laptop can now address the frame to phone without another question.
14:40:59.680051 02:77:10:00:00:10 > 02:77:10:00:00:11, ethertype IPv4 (0x0800), length 98: 10.77.10.10 > 10.77.10.11: ICMP echo request, id 161, seq 1, length 64 - Ping reply. phone to laptop. Phone returns the answer directly to laptop.
14:40:59.680067 02:77:10:00:00:11 > 02:77:10:00:00:10, ethertype IPv4 (0x0800), length 98: 10.77.10.11 > 10.77.10.10: ICMP echo reply, id 161, seq 1, length 64
Check your answer
No. An ARP reply answers the question. Phone sends it only to laptop’s 02:77:10:00:00:10. Its answer supplies phone’s 02:77:10:00:00:11.
| Message | From | To (link address) | Question or answer |
|---|---|---|---|
| ARP request | laptop | ff:ff:ff:ff:ff:ff |
Who has phone’s IP address? |
| ARP reply | phone | 02:77:10:00:00:10 |
Phone supplies its MAC address |
| Ping request | laptop | 02:77:10:00:00:11 |
Test phone |
| Ping reply | phone | 02:77:10:00:00:10 |
Answer laptop |
Read the answer and reuse it
Section titled “Read the answer and reuse it”Read the ARP answer
14:40:59.680049 02:77:10:00:00:11 > 02:77:10:00:00:10, ethertype ARP (0x0806), length 42: Reply 10.77.10.11 is-at 02:77:10:00:00:11, length 2802:77:10:00:00:1102:77:10:00:00:10Reply 10.77.10.11 is-at 02:77:10:00:00:11Reading the output
Pick a step to match a marked part of the output to the picture.
ping -c 1 10.77.10.11, on Ubuntu 24.04.5 LTS, netlab 1.0, tcpdump 4.99.4. The values are the capture's. Read the ARP reply's link destination separately from the IP-to-MAC association it reports.Steps (4)
- Source. Source: 02:77:10:00:00:11. Link layer. Shown on laptop's eth0 as: Link source. The first MAC address is phone, which sent this frame.
- Destination. Destination: 02:77:10:00:00:10. Link layer. Shown on laptop's eth0 as: Link destination. The reply is addressed only to laptop. It is not a broadcast.
- Carried type. Carried type: ARP (0x0806). Link layer. Shown on laptop's eth0 as: eth0. EtherType identifies ARP, rather than an IPv4 packet.
- Answer. Answer: Reply 10.77.10.11 is-at 02:77:10:00:00:11. Link layer. Shown on laptop's eth0 as: Neighbor answer. Read the IP address and the MAC address it belongs to together.
The table read after ping shows lladdr before the MAC address and REACHABLE after it. That state means Linux recently confirmed this neighbor. The second ping completes with that entry already present. In the exchange stage, one ARP question and answer are followed by the ping request and reply. Its capture point, laptop:eth0, does not observe the whole lab.
Mistakes to recognize
Section titled “Mistakes to recognize”“ARP finds any machine on the Internet.” The stage’s broadcast stays on home. In Local delivery and gateway delivery, watch laptop ask for router, not web, when the destination is remote.
“ARP runs before every packet.” The exchange stage has one ARP question before the ping request and reply. A usable table entry can be reused.
Good to know
Section titled “Good to know”Neighbor states change as entries age. Read promptly when comparing REACHABLE. Times, ping identifiers and round-trip times vary; your number will differ.
ARP does not check who is entitled to answer. A local device can answer falsely and receive traffic meant for another device. A changing MAC entry or different answers to one question are reasons to investigate.
Try it yourself
Section titled “Try it yourself”Predict the two ARP directions when phone reaches router. In terminal 1 enter phone, clear its table as above, read it, then run sudo tcpdump -n -e -i eth0 arp. In terminal 2 enter phone and run ping -c 1 10.77.10.1, then ip neigh. Return and press Ctrl+C. Compare the question and answer with your prediction.
Solution
learner@phone:~$ sudo ip neigh flush dev eth0[sudo] password for learner: learner@phone:~$ ip neighlearner@phone:~$ sudo tcpdump -n -e -i eth0 arptcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes14:41:31.962746 02:77:10:00:00:11 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.77.10.1 tell 10.77.10.11, length 28
14:41:31.962790 02:77:10:00:00:01 > 02:77:10:00:00:11, ethertype ARP (0x0806), length 42: Reply 10.77.10.1 is-at 02:77:10:00:00:01, length 28^C2 packets captured
2 packets received by filter
0 packets dropped by kernellearner@phone:~$ Steps (14)
- Type
sudo ip neigh flush dev eth0 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Type
ip neigh - Press Enter
- Type
sudo tcpdump -n -e -i eth0 arp - Press Enter
- Output:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes - A second phone terminal reached router. Return here and stop the listener.
- Output:
14:41:31.962746 02:77:10:00:00:11 > ff:ff:ff:ff:ff:ff, ethertype ARP (0x0806), length 42: Request who-has 10.77.10.1 tell 10.77.10.11, length 28 14:41:31.962790 02:77:10:00:00:01 > 02:77:10:00:00:11, ethertype ARP (0x0806), length 42: Reply 10.77.10.1 is-at 02:77:10:00:00:01, length 28 - Press Ctrl + C
- Output:
2 packets captured 2 packets received by filter 0 packets dropped by kernel
learner@phone:~$ ping -c 1 10.77.10.1PING 10.77.10.1 (10.77.10.1) 56(84) bytes of data.
64 bytes from 10.77.10.1: icmp_seq=1 ttl=64 time=0.078 ms
--- 10.77.10.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.078/0.078/0.078/0.000 mslearner@phone:~$ ip neigh10.77.10.1 dev eth0 lladdr 02:77:10:00:00:01 REACHABLE learner@phone:~$ Steps (6)
- Type
ping -c 1 10.77.10.1 - Press Enter
- Output:
PING 10.77.10.1 (10.77.10.1) 56(84) bytes of data. 64 bytes from 10.77.10.1: icmp_seq=1 ttl=64 time=0.078 ms --- 10.77.10.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.078/0.078/0.078/0.000 ms - Type
ip neigh - Press Enter
- Output:
10.77.10.1 dev eth0 lladdr 02:77:10:00:00:01 REACHABLE
Phone broadcasts its question. Router answers phone directly with 02:77:10:00:00:01 for 10.77.10.1.
- Ask locally for an unknown neighbor address.
- Read the answer’s IP and MAC association.
- Reuse a remembered entry for later packets.
Next, Local delivery and gateway delivery chooses which neighbor to ask for.