Neighbor Discovery in depth
Trace a neighbour cache entry through the Neighbor Unreachability Detection (NUD) states and calculate the timers involved. Explain Duplicate Address Detection, Redirects and gratuitous Neighbor Advertisements (RFC 9131). Read NS and NA messages in a capture, including their flags and options. Diagnose common Neighbor Discovery failures from packet captures and the neighbour table.
Take the quiz · pass mark 70% · 9 questions
Explanation
Level 1 (L1.05) showed the basic NS/NA exchange that replaces ARP. On a real LAN you also need to know what the host does after it has learned a neighbour's link-layer address: how it decides the neighbour is still there, how it notices that it is not, and how addresses are checked for duplicates. All of this is in RFC 4861 (Neighbor Discovery) and RFC 4862 (SLAAC, including DAD).
The five ND messages
| ICMPv6 type | Message | Sent to | Main use |
|---|---|---|---|
| 133 | Router Solicitation (RS) | ff02::2 | Ask routers to send an RA now (L3.02) |
| 134 | Router Advertisement (RA) | ff02::1 or the soliciting host | Default router, prefixes, options (L3.02) |
| 135 | Neighbor Solicitation (NS) | Solicited-node multicast, or unicast | Address resolution, NUD probes, DAD |
| 136 | Neighbor Advertisement (NA) | Unicast to the solicitor, or ff02::1 / ff02::2 | Answer an NS, or announce a change |
| 137 | Redirect | Unicast to the host | Tell a host about a better first hop |
Every ND message is sent with Hop Limit 255, and receivers drop ND messages with any other value. A packet that crossed a router would arrive with 254 or less, so this check proves the sender is on the link.
An NA carries three flags:
- R (Router): the sender is a router. A host that sees R change from 1 to 0 removes that router from its default router list.
- S (Solicited): the NA answers an NS. Only a solicited NA confirms reachability.
- O (Override): the NA should replace an existing cached link-layer address. A host normally sets O for its own unicast addresses. Anycast responders leave it clear so they do not overwrite each other.
The useful options are Source Link-Layer Address (in NS and RS) and Target Link-Layer Address (in NA and Redirect).
The neighbour cache and NUD
Each host keeps a neighbour cache with an entry for every neighbour it is talking to. RFC 4861 defines five states:
Drawing diagram…
- INCOMPLETE: address resolution is in progress. The host sends a multicast NS to the target's solicited-node address, up to
MAX_MULTICAST_SOLICIT(3) times,RetransTimer(1,000 ms) apart. If no NA arrives, resolution fails after about 3 seconds, and the host returns ICMPv6 Destination Unreachable, code 3 (address unreachable, RFC 4443), for queued packets. - REACHABLE: reachability was confirmed recently. Confirmation comes from a solicited NA, or from upper-layer hints such as TCP acknowledgements.
- STALE:
ReachableTimehas passed without a confirmation, or the address was learned from an unsolicited message. The host still uses the cached address. Nothing happens until it sends a packet. - DELAY: the host has just sent a packet using a STALE entry. It waits
DELAY_FIRST_PROBE_TIME(5 s) for an upper-layer confirmation before probing, which avoids probing during a normal TCP exchange. - PROBE: the host sends unicast NS probes, up to
MAX_UNICAST_SOLICIT(3) times,RetransTimerapart. A solicited NA returns the entry to REACHABLE. No answer means the entry is deleted.
ReachableTime is not fixed. It is a random value between MIN_RANDOM_FACTOR (0.5) and MAX_RANDOM_FACTOR (1.5) times BaseReachableTime, whose default is REACHABLE_TIME (30,000 ms), so it lies between 15 and 45 seconds. The randomness stops all hosts from probing at the same moment. A router can advertise other values for Reachable Time and Retrans Timer in its RAs.
Linux shows these states (plus its own FAILED, NOARP and PERMANENT) with ip -6 neigh:
2001:db8:3000:10::1 dev eth0 lladdr 52:54:00:0a:00:01 router REACHABLE
2001:db8:3000:10::80 dev eth0 lladdr 52:54:00:0a:00:80 STALE
fe80::5054:ff:fe0a:1 dev eth0 lladdr 52:54:00:0a:00:01 router DELAY
On Windows use Get-NetNeighbor -AddressFamily IPv6 (or netsh interface ipv6 show neighbors), and on macOS ndp -an.
Duplicate Address Detection
Before a node uses a unicast address, including its link-local address, it runs DAD (RFC 4862, section 5.4):
- The address is tentative: the node cannot use it as a source yet.
- The node joins the solicited-node group of the tentative address and sends an NS with source
::(the unspecified address), destination the solicited-node multicast address of the tentative address, and target the tentative address. It sendsDupAddrDetectTransmitsof these (default 1),RetransTimerapart. - If an NA for the target arrives, or another node's DAD NS for the same target arrives, the address is a duplicate and is not used. Linux marks it
dadfailed. - If nothing arrives within the wait time, the address becomes preferred (or deprecated, depending on its lifetime).
With the defaults, DAD takes about 1 second per address. Optimistic DAD (RFC 4429) lets a node use a new address while DAD runs, with restrictions, to speed up attachment. Linux has an optimistic_dad sysctl for it.
If the duplicate is a link-local address based on the MAC address, the hardware itself is probably duplicated. RFC 4862 says the node should then disable IP operation on that interface. Linux does this only if accept_dad is 2.
Redirects
A router sends a Redirect (type 137) when it forwards a packet out of the same interface it arrived on and the source is an on-link neighbour. The Redirect tells the host either that a better router exists on the link for that destination, or that the destination itself is on-link. The Redirect is only accepted if it comes from the current first-hop router for that destination (checked by its link-local source address) with Hop Limit 255. Hosts should process Redirects. Many security baselines disable them (Level 5), and Linux has accept_redirects for that.
Gratuitous Neighbor Discovery (RFC 9131)
A new address creates a timing problem. A host forms a new global address (for example a new temporary address) and immediately opens a connection to the Internet. The reply arrives at the router, which has no neighbour cache entry for the new address. The router must run address resolution first, and while it does, it buffers at most a packet or two. Replies can be lost.
RFC 9131 updates RFC 4861 in two ways:
- Hosts should send up to
MAX_NEIGHBOR_ADVERTISEMENT(3) unsolicited NAs to the all-routers addressff02::2when a new global address becomes preferred (or as soon as an optimistic address is assigned). The Override flag should not be set. - Routers that receive an NA for an address they have no entry for should create a STALE entry, instead of discarding it as RFC 4861 required.
On Linux routers, this behaviour is controlled by the accept_untracked_na sysctl, which is off by default. Check what your router platform supports before relying on it.
Diagnosing ND from captures
Use a capture filter for ND only. ip6[40] is the first byte after the 40-byte IPv6 header, which is the ICMPv6 type when there are no extension headers:
sudo tcpdump -ni eth0 'icmp6 and ip6[40] >= 133 and ip6[40] <= 137'
Common patterns:
| Symptom in the capture | Likely cause |
|---|---|
| Repeated multicast NS for the same target, no NA | Target down, wrong VLAN, or multicast filtered (MLD snooping problems, L3.05) |
| NA arrives, but the cache entry stays INCOMPLETE | Hop Limit not 255 (relayed or tunnelled ND), or a firewall dropping ICMPv6 on the host |
DAD NS from :: answered by an NA | Duplicate address: static address reused, cloned VM with a fixed IID, or a host misconfigured with the router's address |
| Unicast NS probes to a router keep repeating, then traffic stops | The router's link-layer address changed (failover without unsolicited NA) or the router is overloaded |
| Thousands of NS for different targets in one /64 | Scanning or ND cache exhaustion attack (Level 5) |
Worked examples
Example 1: The ReachableTime range
With BaseReachableTime = 30,000 ms, ReachableTime is drawn from 0.5 × 30,000 = 15,000 ms to 1.5 × 30,000 = 45,000 ms.
Example 2: How long until a dead neighbour is detected?
A host has a STALE entry for 2001:db8:3000:10::80, which has just been switched off. The host sends a packet. The entry moves to DELAY for 5 s, then to PROBE. Three unicast probes are sent, 1 s apart, and the host waits 1 s after the last one. The entry is removed 5 + 3 × 1 = 8 seconds after the first packet.
Example 3: Address resolution failure
A host sends to an on-link address nobody owns. It sends 3 multicast NS, 1 s apart, and gives up 3 seconds after the first, returning Destination Unreachable code 3 to the application.
Example 4: A DAD probe
A host on 2001:db8:3000:10::/64 tests the tentative address 2001:db8:3000:10::25. The DAD NS has source ::, destination ff02::1:ff00:25 (the solicited-node address: ff02::1:ff followed by the last 24 bits), and target 2001:db8:3000:10::25. On Ethernet it goes to MAC 33:33:ff:00:00:25.
Example 5: A Redirect
Hosts on 2001:db8:3000:10::/64 use router A (fe80::1) as default. Router B (fe80::2) on the same link reaches 2001:db8:3000:9000::/52. A host sends a packet for 2001:db8:3000:9001::5 to A. A forwards it to B over the same interface and sends the host a Redirect with target fe80::2 and destination 2001:db8:3000:9001::5. Later packets for that destination go straight to B.
Lab
Goal: Watch NUD states change, force a DAD conflict, and identify each case in a capture.
You need: Linux with root, iproute2, tcpdump or Wireshark. Three namespaces on one bridge: r1 (router), h1 and h2 (hosts), using the LAN 2001:db8:3000:10::/64 from the L2.04 enterprise plan.
Step 1: Build the LAN
sudo ip link add br0 type bridge && sudo ip link set br0 up
for n in r1 h1 h2; do
sudo ip netns add $n
sudo ip link add v-$n type veth peer name eth0 netns $n
sudo ip link set v-$n master br0 up
sudo ip -n $n link set eth0 up
done
sudo ip -n r1 addr add 2001:db8:3000:10::1/64 dev eth0
sudo ip -n h1 addr add 2001:db8:3000:10::25/64 dev eth0
sudo ip -n h2 addr add 2001:db8:3000:10::80/64 dev eth0
Start a capture on br0 with the ND filter above, written to a file.
Step 2: Watch NUD
sudo ip netns exec h1 ping -c1 2001:db8:3000:10::80
watch -n1 sudo ip -n h1 -6 neigh show dev eth0
Record the state after the ping, and the time it takes to become STALE. Then shut down h2's interface (sudo ip -n h2 link set eth0 down), ping again, and record the DELAY and PROBE states and when the entry disappears or becomes FAILED. Compare your timings with Example 2.
Step 3: Force a DAD conflict
Add 2001:db8:3000:10::80/64 to h1 while h2 (brought back up) still has it:
sudo ip -n h2 link set eth0 up
sudo ip -n h1 addr add 2001:db8:3000:10::80/64 dev eth0
sudo ip -n h1 -6 addr show dev eth0
Note the tentative and then dadfailed flags. Find the DAD NS (source ::) and the NA from h2 in the capture.
Step 4: Gratuitous NA (optional)
Make r1 a router and turn on the RFC 9131 router behaviour (the sysctl only acts on routers):
sudo ip netns exec r1 sysctl -w net.ipv6.conf.all.forwarding=1
sudo ip netns exec r1 sysctl -w net.ipv6.conf.eth0.accept_untracked_na=1
sudo ip netns exec h2 sysctl -w net.ipv6.conf.eth0.ndisc_notify=1
sudo ip -n r1 -6 neigh flush dev eth0
sudo ip -n h2 link set eth0 down && sudo ip -n h2 link set eth0 up
sudo ip -n r1 -6 neigh show dev eth0
With ndisc_notify=1, Linux sends unsolicited NAs when the interface comes up. Show that r1 now has a STALE entry for h2 that it never asked for, then repeat with accept_untracked_na=0 and compare. The sysctl is relatively new (Linux 5.19 or later); on older kernels, record that it is missing.
What to submit
The neighbour table outputs with timings, the dadfailed output, and annotated screenshots or text output of the capture for each step.
Summary
- ND has five messages (RS, RA, NS, NA, Redirect), all sent with Hop Limit 255. NA flags R, S and O mean router, solicited and override.
- NUD states: INCOMPLETE → REACHABLE → STALE → DELAY → PROBE. ReachableTime is random between 15 and 45 s by default. A dead neighbour is detected about 8 s after the first packet to a STALE entry, and a failed resolution after about 3 s.
- DAD sends an NS from
::to the solicited-node address of the tentative address. Any answer means a duplicate (dadfailedon Linux). Optimistic DAD (RFC 4429) reduces the delay. - Redirects point a host at a better on-link router or an on-link destination.
- RFC 9131: hosts announce new addresses with unsolicited NAs to
ff02::2, and routers create STALE entries for them. - Next lesson (L3.02): the Router Advertisement in detail.
Quiz imported · 9 questions · pass mark 70%. Lab questions are not auto-marked.