Sub topic 11
IPv6 Neighbor Discovery replaces ARP
This chapter assumes you know how ARP resolves an IPv4 address to a MAC address, what a switch's MAC table does, and the difference between unicast and multicast MAC addresses. You should also be able to read IPv6 addresses and run commands in a terminal.
IPv6 has no ARP. The job of mapping a next-hop IP address to a MAC address moved into ICMPv6, in a protocol called Neighbor Discovery (ND, defined in RFC 4861). It does more than ARP did. It also finds routers, detects duplicate addresses, and checks whether a neighbor is still reachable.
Why ARP was not carried over
ARP is its own protocol with its own EtherType (0x0806), and it sits beside IP, not on top of it. Every ARP request is a link-layer broadcast. Every host on the segment must receive it and process it, even though only one host is the target.
IPv6 changed three things:
- Resolution runs over ICMPv6. Neighbor Discovery messages are ICMPv6 packets inside normal IPv6 packets, so they use the same stack, firewalls, and tooling as other IPv6 traffic.
- Multicast replaces broadcast. IPv6 has no broadcast address. A resolution request goes to a multicast group that only a few hosts have joined.
- One protocol covers several jobs. Router discovery (done by ICMP Router Discovery or DHCP in IPv4), address conflict checks, and reachability tracking are all part of ND.
The five ICMPv6 message types
| ICMPv6 type | Name | Purpose |
|---|---|---|
| 133 | Router Solicitation (RS) | A host asks routers to announce themselves now |
| 134 | Router Advertisement (RA) | A router announces prefixes, its role as a gateway, and parameters |
| 135 | Neighbor Solicitation (NS) | "Who has this IPv6 address? Tell me your MAC." Also used for duplicate detection and reachability probes |
| 136 | Neighbor Advertisement (NA) | The answer to an NS, or an unsolicited update |
| 137 | Redirect | A router tells a host about a better first hop |
This chapter focuses on NS and NA, the direct counterparts of an ARP request and reply. The MAC address travels inside an ND option. The Source Link-Layer Address option (type 1) appears in NS and RS messages. The Target Link-Layer Address option (type 2) appears in NA messages.
Solicited-node multicast: avoiding the broadcast
If a host sent every NS to ff02::1 (all nodes), it would be no better than ARP. Instead, each IPv6 address maps to a solicited-node multicast address. You build it by taking the prefix ff02::1:ff00:0/104 and appending the last 24 bits of the unicast address.
For 2001:db8::a1b2:c3d4, the last 24 bits are b2:c3d4. The solicited-node address is ff02::1:ffb2:c3d4.
That IPv6 multicast address then maps to an Ethernet multicast MAC address. The rule is 33:33 followed by the last 32 bits of the IPv6 address. Here that gives 33:33:ff:b2:c3:d4. This is a multicast MAC, so the group bit (the least significant bit of the first octet) is set. 0x33 is 0011 0011, so the bit is 1.
Every host joins the solicited-node group for each of its unicast addresses. Only hosts whose addresses share the same last 24 bits receive the NS, which in practice means one host. Its network card can filter by that multicast MAC, so other hosts' CPUs never see the packet.
import ipaddress
BASE = int(ipaddress.IPv6Address("ff02::1:ff00:0"))
def solicited_node(addr: str) -> tuple[str, str]:
"""Return (solicited-node IPv6 group, Ethernet multicast MAC)."""
low24 = int(ipaddress.IPv6Address(addr)) & 0xFFFFFF
group = ipaddress.IPv6Address(BASE | low24)
mac_bytes = bytes([0x33, 0x33, 0xFF]) + low24.to_bytes(3, "big")
mac = ":".join(f"{b:02x}" for b in mac_bytes)
return str(group), mac
for a in ("2001:db8::a1b2:c3d4", "fe80::1"):
print(a, "->", solicited_node(a))The output is:
2001:db8::a1b2:c3d4 -> ('ff02::1:ffb2:c3d4', '33:33:ff:b2:c3:d4')
fe80::1 -> ('ff02::1:ff00:1', '33:33:ff:00:00:01')Because only 24 bits are used, two addresses on one segment can collide in the same group. That is harmless. Both hosts receive the NS, and only the real target answers.
The resolution exchange
Suppose host A (fe80::a) wants to send to host B (fe80::b) on the same link, and has no cache entry for B.
- A queues the outgoing packet and creates a neighbor cache entry for B in the INCOMPLETE state.
- A sends an NS. The IPv6 source is A's address, the destination is B's solicited-node group, and the target field inside the message is
fe80::b. The Ethernet destination is the matching33:33:ff:...multicast MAC. The message includes A's MAC in the Source Link-Layer Address option. - B receives the NS and records A's MAC from the option. This is why B can reply without doing its own resolution.
- B sends a unicast NA straight to A's MAC. The NA carries B's MAC in the Target Link-Layer Address option and has the Solicited (S) flag set.
- A stores B's MAC, marks the entry REACHABLE, and sends the queued packet.
An NS or NA is only valid if its IPv6 hop limit is 255. A router decrements the hop limit, so a packet that arrives with 255 cannot have crossed a router. Receivers discard any ND message with a different value. This stops off-link attackers from injecting ND messages.
The neighbor cache and reachability tracking
ARP caches entries and ages them out with a timer. ND keeps a neighbor cache with an explicit state per entry, and it uses that state to check whether the neighbor still answers (Neighbor Unreachability Detection, NUD).
| State | Meaning |
|---|---|
| INCOMPLETE | Resolution is in progress and no MAC is known yet |
| REACHABLE | The neighbor was confirmed reachable recently |
| STALE | The reachable time expired. The MAC is still used, but not yet re-verified |
| DELAY | A packet was sent to a STALE entry. The host waits briefly for upper-layer confirmation, such as a TCP acknowledgment |
| PROBE | The host is sending unicast NS messages to confirm reachability |
| FAILED | Probing got no answer and the entry is unusable |
This design is cheaper than refreshing every entry on a timer. A host only probes neighbors it is actually sending to, and TCP acknowledgments can confirm reachability without any ND traffic at all.
Linux shows these states directly:
# IPv6 neighbor cache with state (REACHABLE, STALE, DELAY, PROBE, FAILED)
ip -6 neigh show
# Example line:
# fe80::a00:27ff:fe4e:66a1 dev eth0 lladdr 08:00:27:4e:66:a1 router REACHABLEThe router flag means the neighbor has advertised itself as a router. It came from the R flag in that neighbor's NA or RA.
Duplicate Address Detection
Before a host uses a new unicast address, it must check that nobody else on the link has it. This is Duplicate Address Detection (DAD). The address is "tentative" during the check.
The host sends an NS where the target is the tentative address. The source is the unspecified address ::, because the host cannot yet use the address it is testing. The destination is the solicited-node group of the tentative address. If another host already uses the address, it replies with an NA, and the new host abandons the address. If nothing answers within the retransmit interval, the address becomes preferred.
DAD is how SLAAC (stateless address autoconfiguration, where a host builds its own address from an RA prefix) stays safe without a central server. It is also why a new IPv6 address can show as tentative for about a second in ip -6 addr output.
ARP and ND side by side
| Feature | ARP (IPv4) | Neighbor Discovery (IPv6) |
|---|---|---|
| Carried in | Own protocol, EtherType 0x0806 | ICMPv6 inside IPv6 |
| Request destination | Ethernet broadcast `ff:ff:ff:ff:ff:ff` | Solicited-node multicast |
| Hosts interrupted | Every host on the segment | Usually only the target |
| Reachability checks | Cache timeout and re-ARP | NUD with explicit states |
| Duplicate address check | Optional gratuitous ARP | Built-in DAD |
| Router discovery | Separate (DHCP, static) | RS and RA in the same protocol |
| Built-in authentication | None | None by default (SEND is optional and rarely deployed) |
Common errors and gotchas
- Blocking all ICMPv6. Firewall rules copied from IPv4 habits often drop ICMP. Dropping types 133 to 137 breaks IPv6 on the link, because hosts can no longer resolve neighbors.
- Multicast filtering in switches. Some switches with MLD or IGMP snooping misdeliver solicited-node traffic, so resolution fails intermittently. Check the switch's multicast table before blaming the host.
- Large neighbor tables. A router that receives traffic for a whole /64 can be made to create a huge number of INCOMPLETE entries by a scan. Rate-limit ND and size the cache accordingly.
- Reading STALE as broken. A STALE entry is normal. It means "not verified recently," not "bad."
- Changing MACs. If an interface's MAC changes, neighbors keep the old mapping until their entry expires or the host sends an unsolicited NA with the Override (O) flag set.
Exercise
A host has the IPv6 address 2001:db8:10::7f:3a5c. What are its solicited-node multicast IPv6 address and the matching Ethernet multicast MAC address?
Show answer
The last 24 bits of the address are 7f:3a5c, which is 0x7f3a5c. The solicited-node address is ff02::1:ff7f:3a5c. The Ethernet MAC is 33:33 followed by the last 32 bits of that IPv6 address, giving 33:33:ff:7f:3a:5c.
Exercise
Host A sends a Neighbor Solicitation with an IPv6 hop limit of 64 and a source on another network. Should the receiver accept it, and what does this tell you about how ND is protected?
Show answer
The receiver must discard it. Valid ND messages have a hop limit of 255, which proves they were not forwarded by a router, since each router decrements the hop limit. This check keeps off-link senders from injecting ND messages. It does not stop a malicious host that is on the same link.