Linux › Section I · Your network and its configuration › Topic I.13

ARP, NDP, and wireless Ethernet

One last piece connects IP to Ethernet: before a frame can be sent, the kernel must learn the hardware address behind an IP address. This topic shows that neighbour table on Linux, then looks at the extra machinery a wireless interface needs before IP can even begin.

From IP address to MAC address

An IP datagram travels across Ethernet inside a frame, and a frame is addressed by MAC address, not IP address. So before sending, the host must answer a question: which MAC address belongs to this next-hop IP address? For IPv4 the answer comes from the Address Resolution Protocol (ARP), described in the Networking topic Switched LANs: MAC addresses, ARP, switches, and VLANs. The host broadcasts a request asking who owns the address, the owner replies with its MAC address, and the host stores the pair in a cache. On Linux that cache lives in the kernel, as part of the neighbour table.

Viewing neighbours with ip neigh

ip neigh, short for ip neighbour, shows the neighbour table; ip -4 neigh limits it to IPv4 (ARP) entries and ip -6 neigh to IPv6. An illustrative line reads 192.168.1.1 dev wlp2s0 lladdr 02:00:00:00:00:01 REACHABLE: the IP address, the interface, the link-layer address and the entry's state. The manual page ip-neighbour(8) lists the states. REACHABLE means recently confirmed; STALE means still usable but due for checking; DELAY and PROBE mean checking is in progress; FAILED means no reply came; PERMANENT marks an entry added by hand. The legacy command arp -n shows the IPv4 part in an older format.

Only neighbours on the link

The table holds only hosts on directly attached links, because ARP requests are broadcasts that never cross a router. To send to a web server at 203.0.113.80, a laptop on 192.168.1.0/24 does not look for the server's MAC address at all. Its routing table says the next hop is the gateway, 192.168.1.1, so it resolves the gateway's MAC address and puts that in the frame, while the datagram inside still carries 203.0.113.80. That is why the gateway is almost always in the neighbour table of a working host, and why a FAILED gateway entry explains a dead connection at once.

Worked example: reading the neighbour table

ip neigh on a laptop prints (illustrative): 192.168.1.1 dev wlp2s0 lladdr 02:00:00:00:00:01 REACHABLE; 192.168.1.50 dev wlp2s0 lladdr 02:00:00:00:00:32 STALE; 192.168.1.77 dev wlp2s0 FAILED; fe80::1 dev wlp2s0 lladdr 02:00:00:00:00:01 router REACHABLE. 1. The gateway, 192.168.1.1, answered recently. 2. The storage box at .50 has not been heard from for a while, but its entry will be used and rechecked. 3. .77 never answered: it is off, absent, or not on this subnet. 4. The IPv6 entry is the router's link-local address, with the same MAC, flagged router. Check: no internet addresses appear, because only on-link next hops are resolved.

Fixing a stale entry

Entries refresh themselves, so you rarely touch the table. The exception is when an IP address moves to a different network card, for example when a test server is swapped, and neighbours briefly keep the old MAC address. As root, ip neigh del 192.168.1.50 dev wlp2s0 removes one entry, and ip neigh flush dev wlp2s0 clears every entry learned on that interface; the next packet triggers a fresh lookup. Do not confuse ARP with RARP, an obsolete protocol that went the other way, from MAC address to IP address, for diskless machines before DHCP took over the job.

IPv6: Neighbor Discovery

IPv6 has no ARP. Its Neighbor Discovery Protocol (NDP), carried in ICMPv6 as the Networking topic ICMP explains, does the same job with neighbour solicitations, which ask for a neighbour's link-layer address, and neighbour advertisements, which answer them. Instead of broadcasting, solicitations go to a multicast address that only the target is likely to be listening on. NDP also includes the router solicitations and advertisements behind SLAAC, from DHCP and automatic IPv6 configuration. This is why the command is ip neigh rather than ip arp: one table holds both protocols' results.

What wireless adds

Wi-Fi interfaces look like Ethernet to everything above the link layer: they have MAC addresses, the kernel hands their traffic up as Ethernet-style frames, and they get IP addresses and routes in the usual way. The differences sit at the bottom. A radio needs a frequency band and channel. More than one network can share the same airwaves, so each is identified by its SSID, the network name. Most networks are managed by access points, and access points usually require authentication, then encrypt every frame. Only after the interface has joined, authenticated and set up encryption can DHCP or SLAAC run. The protocols are covered in the Networking topic Wireless LANs: 802.11.

The tools underneath

iw talks to the kernel's wireless subsystem and replaces the deprecated iwconfig. ip link finds the interface name, such as wlp2s0; iw dev wlp2s0 scan lists nearby networks (scanning usually needs root), and iw dev wlp2s0 link shows the network you are joined to, including the access point's MAC address and the signal strength. iw can join only open networks, or obsolete WEP ones, by itself. Encryption is handled by a supplicant: wpa_supplicant, configured by a file and documented in wpa_supplicant(8), or Intel's newer iwd, controlled with iwctl. rfkill list shows whether a radio is blocked, and rfkill unblock wifi lifts a software block; a hardware switch must be flipped by hand.

Worked example: joining Wi-Fi with nmcli

In practice NetworkManager drives these tools for you. 1. nmcli radio wifi should print enabled; if not, nmcli radio wifi on, and check rfkill list for a hardware block. 2. nmcli device wifi list shows networks with their SSID, channel, signal and security, such as WPA2 or WPA3. 3. nmcli --ask device wifi connect Library-WiFi asks for the password instead of leaving it in your shell history, then saves a profile. 4. iw dev wlp2s0 link confirms the association and signal. 5. ip address and ip route should now show a DHCP address and default route. Check: the profile reconnects automatically next time, as Configuring interfaces and network managers described.

Common mistakes to avoid

First, expecting the neighbour table to list remote internet hosts; it holds only on-link next hops, chiefly the gateway. Second, reading STALE as broken; the entry is still used and rechecked. Third, looking for ARP in IPv6; NDP does the job, and ip neigh shows both. Fourth, typing a Wi-Fi password on the command line where it lands in history; use nmcli --ask. Fifth, joining WEP or original WPA networks; both are broken, so use WPA2 or WPA3, as Securing wireless LANs and cellular networks explains. Sixth, troubleshooting IP on a wireless interface that rfkill has blocked.

Key takeaways

ARP maps IPv4 next-hop addresses to MAC addresses by broadcast; IPv6 uses NDP over ICMPv6. Linux keeps both in one kernel neighbour table, shown by ip neigh (ip -4 neigh, ip -6 neigh), with states such as REACHABLE, STALE, FAILED and PERMANENT; ip neigh del and ip neigh flush clear entries, and arp is legacy. Only on-link hosts appear, so off-subnet traffic uses the gateway's MAC. Wi-Fi adds channels, SSIDs, access points, authentication and encryption below IP: iw scans and shows links, wpa_supplicant or iwd handles WPA2 and WPA3, rfkill controls radios, and nmcli device wifi ties it together.

Flashcards

Flashcard

ARP

Finds the MAC address for an IPv4 address on the local link

Broadcast request, unicast reply.

Test your understanding

Question 1 of 5

A laptop on 192.168.1.0/24 with gateway 192.168.1.1 sends data to 203.0.113.80. Whose MAC address goes in the Ethernet frame?

Question 2 of 5

ip neigh shows 192.168.1.50 dev wlp2s0 lladdr 02:00:00:00:00:32 STALE. What does STALE mean?

Question 3 of 5

Which statement about IPv6 address resolution on Linux is correct?

Question 4 of 5

iw dev wlp2s0 link works, but connecting to a WPA2 network with iw alone fails. Why?

Question 5 of 5

A laptop's Wi-Fi shows no networks, and rfkill list reports Soft blocked: yes. What should you run?

← Previous topicNext topic →