Sub topic 11
IPv6 Neighbor Discovery replaces ARP
This chapter assumes you know how ARP maps an IPv4 address to a MAC address, and that you can read IPv6 addresses and run commands in a terminal. IPv6 has no ARP. The same job is done by the Neighbor Discovery Protocol (NDP), which is built on ICMPv6 instead of being a separate link-layer protocol.
What changes from ARP
ARP sends a broadcast frame that every host on the LAN must process. NDP avoids that by sending a multicast to a small group of hosts. NDP messages are ICMPv6 packets carried inside normal IPv6 packets.
| Message | ICMPv6 type | Purpose |
|---|---|---|
| Neighbor Solicitation (NS) | 135 | Asks "who has this IPv6 address?" |
| Neighbor Advertisement (NA) | 136 | Answers with the MAC address |
| Router Solicitation (RS) | 133 | Asks routers to announce themselves |
| Router Advertisement (RA) | 134 | Announces prefixes and the default router |
NDP also covers jobs that IPv4 spreads across other protocols: finding routers, learning the local prefix, and detecting duplicate addresses.
The solicited-node multicast address
To resolve an address, a host does not flood the whole LAN. It sends the NS to the target's solicited-node multicast address. This address is ff02::1:ff followed by the last 24 bits of the target IPv6 address.
That IPv6 multicast address maps to an Ethernet multicast MAC. The MAC is 33:33 followed by the last 32 bits of the IPv6 address. Only hosts whose addresses share those last 24 bits listen to the group, so most hosts ignore the frame in their network card.
import ipaddress
def solicited_node(addr: str) -> tuple[str, str]:
ip = ipaddress.IPv6Address(addr)
base = int(ipaddress.IPv6Address('ff02::1:ff00:0'))
group = ipaddress.IPv6Address(base | (int(ip) & 0xFFFFFF))
mac = '33:33:' + ':'.join(f'{b:02x}' for b in group.packed[-4:])
return str(group), mac
print(solicited_node('fe80::a00:27ff:fe4e:66a1'))This prints ('ff02::1:ff4e:66a1', '33:33:ff:4e:66:a1'). Note that the destination MAC has the group bit set, as the earlier chapter on multicast addresses described.
The exchange
The NS carries A's own MAC as a source link-layer option, so B can reply by unicast without asking again. A then caches the entry. Unlike an ARP reply, the NA is addressed straight to A.
The neighbor cache and its states
The IPv6 equivalent of the ARP table is the neighbor cache. Each entry has a state:
- INCOMPLETE: a solicitation was sent and no answer has arrived yet.
- REACHABLE: the neighbor answered recently.
- STALE: the reachable time expired. The entry is still used, but it is checked when traffic next uses it.
- DELAY and PROBE: the host is confirming the neighbor is still there with unicast solicitations.
- FAILED: no answer came.
View it on Linux with:
ip -6 neigh showEach line shows an address, the interface, the MAC (lladdr), and the state.
Duplicate Address Detection
Before using a new address, a host sends an NS for that address from the unspecified address ::. If any host answers, the address is a duplicate and must not be used. ARP only offers an optional equivalent, the gratuitous ARP.
Common errors and gotchas
- Blocking all ICMPv6 on a firewall. This breaks NDP, and IPv6 stops working on the link. Allow at least types 133 to 137.
- Looking for ARP traffic in an IPv6 capture. Filter on ICMPv6 instead, for example
icmp6in tcpdump. - Assuming NDP is secure. It is as trusting as ARP. A rogue host can send fake Neighbor Advertisements or Router Advertisements. Defenses such as RA Guard and Secure Neighbor Discovery exist, but are not widely enabled by default.
- Hop limit. Valid NDP packets have a hop limit of 255. Receivers drop anything lower, which shows the packet did not cross a router.
Exercise
A host wants the MAC address of fe80::1:2345:6789. Which solicited-node multicast address and Ethernet destination MAC does it use for the Neighbor Solicitation?
Show answer
The last 24 bits of the address are 0x456789. The multicast address is ff02::1:ff45:6789. The Ethernet destination MAC is 33:33:ff:45:67:89, which is 33:33 followed by the last 32 bits of the multicast address.