Skip to content

Finding a neighbor with ARP

Module
Reaching Another Device
Difficulty
Easy
Updated
Tested on
Ubuntu 24.04.5 LTS, netlab 1.0, GNU Bash 5.2.21, tcpdump 4.99.4
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.

Seven questions from laptop to web A horizontal line joins laptop to web through seven numbered circles. Stations 4 and 5 are the focus. Station 3 is answered; stations 1 and 4 are partly answered. laptop web 1 2 3 4 5 6 7
Seven questions from laptop to web A horizontal line joins laptop to web through seven numbered circles. Stations 4 and 5 are the focus. Station 3 is answered; stations 1 and 4 are partly answered. laptop web 1 2 3 4 5 6 7
Stations 4 and 5 are the focus: finish local delivery, then cross the router and return. Station 3 is answered; stations 1 and 4 are partly answered.
  1. Settings: read and interpreted; their automatic source remains open.
  2. Finding a name: still open, for How DNS Finds Services.
  3. Own network or router: answered in Subnetting Foundations.
  4. Delivery on the cable: frames and switches answered; finding the address comes here.
  5. Crossing and returning: the other focus of Reaching Another Device.
  6. Finding programs: still open, for TCP, UDP, and Ports.
  7. Application words and privacy: still open, for Everyday Application Traffic.

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.

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.

Learn phone’s link address
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Clear laptop's table, read it empty, reach phone, read the learned entry, then reach phone again.
Steps (16)
  1. Type sudo ip neigh flush dev eth0
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Type ip neigh
  7. Press Enter
  8. Type ping -c 1 10.77.10.11
  9. Press Enter
  10. 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
  11. Type ip neigh
  12. Press Enter
  13. Output: 10.77.10.11 dev eth0 lladdr 02:77:10:00:00:11 REACHABLE
  14. Type ping -c 1 10.77.10.11
  15. Press Enter
  16. 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

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

  1. laptop
  2. phone
  3. router
  1. Ask everyone: laptop to phone and router
  2. Phone answers: phone to laptop
  3. Ping request: laptop to phone
  4. Ping reply: phone to laptop

In the capture4 messages at laptop:eth0

  1. 1. Ask everyone14: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. 2. Phone answers14: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. 3. Ping request14: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. 4. Ping reply14: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

Step-by-step model built from captured frames · Frames captured at laptop:eth0 while running 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)
  1. 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
  2. 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
  3. 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
  4. 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 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 28
laptop
machine
eth0 · Link
Link source · Link02:77:10:00:00:11
Link destination · Link02:77:10:00:00:10
Neighbor answer · LinkReply 10.77.10.11 is-at 02:77:10:00:00:11

Reading the output

Pick a step to match a marked part of the output to the picture.

Step-by-step reading of a captured output · Capture line 2 from laptop:eth0 while running 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)
  1. 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.
  2. 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.
  3. Carried type. Carried type: ARP (0x0806). Link layer. Shown on laptop's eth0 as: eth0. EtherType identifies ARP, rather than an IPv4 packet.
  4. 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.

“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.

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.

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
Listen for phone’s ARP exchange
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Phone's first terminal clears its table and listens for ARP.
Steps (14)
  1. Type sudo ip neigh flush dev eth0
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Type ip neigh
  7. Press Enter
  8. Type sudo tcpdump -n -e -i eth0 arp
  9. Press Enter
  10. Output: tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
  11. A second phone terminal reached router. Return here and stop the listener.
  12. 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
  13. Press Ctrl + C
  14. Output: 2 packets captured 2 packets received by filter 0 packets dropped by kernel
Reach router from phone
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Phone's second terminal reaches router and reads the neighbor entry.
Steps (6)
  1. Type ping -c 1 10.77.10.1
  2. Press Enter
  3. 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
  4. Type ip neigh
  5. Press Enter
  6. 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.