Sub topic 13
Neighbor Discovery and Router Advertisements
This chapter assumes you know link-local addresses, multicast scopes, and the ff00::/8 prefix. It also assumes you know what ARP does in IPv4.
What NDP does
The Neighbor Discovery Protocol (NDP) runs on ICMPv6 and replaces ARP. It also finds routers and supplies the prefix information that SLAAC needs. Every NDP message is sent with a hop limit of 255. A receiver drops any message with a lower value, so a packet from off-link cannot pose as a local one.
| Message | ICMPv6 type | Purpose |
|---|---|---|
| Router Solicitation (RS) | 133 | A host asks routers to announce themselves |
| Router Advertisement (RA) | 134 | A router announces prefixes and settings |
| Neighbor Solicitation (NS) | 135 | "Which MAC address owns this IPv6 address?" |
| Neighbor Advertisement (NA) | 136 | The answer to an NS |
| Redirect | 137 | A router points a host to a better next hop |
Router discovery
A host that comes up sends an RS to the all-routers multicast address ff02::2. The router replies with an RA to the sender. Routers also send RAs periodically to ff02::1, the all-nodes address.
An RA carries these main fields:
- Prefix information: the on-link prefix. The A flag allows SLAAC to build an address from it. The L flag marks the prefix as on-link.
- M and O flags: M tells hosts to use DHCPv6 for addresses. O tells them to use DHCPv6 only for other settings, such as DNS servers.
- Router lifetime: how long the router may serve as a default gateway. A value of 0 means it should not.
- MTU option: an optional link MTU.
Address resolution and duplicate detection
To reach an on-link neighbor, a host sends an NS to the neighbor's solicited-node multicast address. This is ff02::1:ff00:0/104 plus the low 24 bits of the target address. Only hosts whose addresses share those 24 bits listen to the group, so the rest of the link is not disturbed.
import ipaddress
def solicited_node(addr):
low24 = int(ipaddress.IPv6Address(addr)) & 0xFFFFFF
base = int(ipaddress.IPv6Address("ff02::1:ff00:0"))
return ipaddress.IPv6Address(base | low24)
print(solicited_node("fe80::21a:2bff:fe3c:4d5e")) # ff02::1:ff3c:4d5eBefore using an address, a host runs Duplicate Address Detection (DAD). It sends an NS for its own tentative address. If an NA answers, the address is taken and the host must not use it.
On Linux you can see the neighbor cache and its states:
ip -6 neigh showEntries move through states such as REACHABLE, STALE, and FAILED.
Common errors
- Blocking ICMPv6 in a firewall. NDP then fails and hosts lose connectivity. Allow types 133 to 137.
- Rogue RAs. Any device on the link can send an RA, for example a laptop with internet sharing turned on. Hosts may adopt it as their default router. Switches can filter RAs with RA Guard.
- No RA, no SLAAC. If the router does not send RAs, hosts get only link-local addresses.
Exercise
A host's address ends in ...:fe3c:4d5e. What is its solicited-node multicast address, and why is that group used instead of ff02::1?
Show answer
It is ff02::1:ff3c:4d5e, built from ff02::1:ff00:0/104 plus the low 24 bits (3c:4d5e). Sending the NS here reaches only hosts whose addresses share those 24 bits. Using ff02::1 would interrupt every host on the link.