Sub topic 14
A short look at IPv6: SLAAC and DHCPv6
This chapter compares how IPv6 hosts get their addresses with the DHCPv4 process from the earlier chapters. It assumes you know the Discover, Offer, Request, Acknowledge exchange, lease timers, DHCP options, and the roles of a default gateway and a DNS server. It also assumes you can read an IPv6 address, including :: shortening and a /64 prefix.
Why IPv6 does it differently
IPv6 has no broadcast. It uses multicast instead, so the DHCPv4 trick of sending to 255.255.255.255 from 0.0.0.0 does not exist. IPv6 also builds in a way for a host to configure itself, without any server that tracks leases. So IPv6 offers two mechanisms, and a network can use either or both:
- SLAAC (Stateless Address Autoconfiguration) lets the host build its own address from a prefix announced by the router.
- DHCPv6 is a server-based protocol similar in spirit to DHCPv4. It can hand out addresses, delegate prefixes, and deliver options such as DNS servers.
Step 1: the link-local address
Before a host talks to anyone, it gives each interface a link-local address in fe80::/10. This address is valid only on the local link. It is the IPv6 counterpart of the 169.254.0.0/16 fallback, but it is always present, whether or not a DHCP server exists.
Historically the 64-bit interface identifier came from the MAC address (EUI-64): split the MAC in half, insert ff:fe in the middle, and flip the universal/local bit (bit 0x02 of the first byte). This script does that:
mac = "aa:bb:cc:dd:ee:ff"
octets = bytearray(int(part, 16) for part in mac.split(":"))
octets[0] ^= 0x02 # flip the universal/local bit
eui64 = bytes(octets[:3]) + b"\xff\xfe" + bytes(octets[3:])
groups = [f"{eui64[i]:02x}{eui64[i + 1]:02x}" for i in range(0, 8, 2)]
interface_id = ":".join(groups)
print("Interface identifier:", interface_id)
print("Link-local address: fe80::" + interface_id)It prints a8bb:ccff:fedd:eeff as the identifier. Modern operating systems usually do not use this format for their global addresses. Embedding the MAC address lets anyone track a device across networks. Windows, Linux, Android, and Apple systems default to stable but opaque identifiers (RFC 7217) or temporary random ones (RFC 8981, "privacy extensions").
Step 2: duplicate address detection
The host does not trust that its tentative address is unique. It sends a Neighbor Solicitation for that address from the unspecified address ::. If another host answers, the address is a duplicate and is not used. If nobody answers, the host keeps it. This check is called Duplicate Address Detection (DAD). DHCPv4 deployments sometimes need an ARP probe or a Decline message (see the NAK, Decline, Release and Inform chapter). In IPv6, DAD is part of every address assignment, including addresses from DHCPv6.
Step 3: Router Advertisements
A host finds its router with Neighbor Discovery messages carried in ICMPv6:
- The host sends a Router Solicitation (ICMPv6 type 133) to the all-routers multicast address
ff02::2. - The router answers with a Router Advertisement (RA) (type 134), sent to
ff02::1(all nodes) or directly to the host. Routers also send unsolicited RAs periodically.
An RA carries the information that DHCPv4 spreads across several options:
| RA content | What it configures | DHCPv4 equivalent |
|---|---|---|
| Router address (source of the RA) and router lifetime | Default gateway | Option 3 (router) |
| Prefix Information option with the A flag | Prefix to use for SLAAC, plus valid and preferred lifetimes | Address and mask |
| Prefix Information option with the L flag | Prefix is on-link, no router needed | Subnet mask |
| M flag (Managed) | Use DHCPv6 to get an address | None |
| O flag (Other) | Use DHCPv6 only for other settings | None |
| RDNSS and DNSSL options (RFC 8106) | DNS servers and search domains | Options 6 and 15 |
| MTU option | Link MTU | Option 26 |
This table points to the biggest conceptual difference. The default gateway in IPv6 comes only from the RA. DHCPv6 has no router option at all. A network that uses only DHCPv6 and no RAs gives hosts no default route.
SLAAC in practice
With SLAAC, the host takes the 64-bit prefix from an RA that has the A flag set, appends its own 64-bit interface identifier, and runs DAD. The result is a global address such as 2001:db8:1:0:a8bb:ccff:fedd:eeff. No server records the assignment. The prefix's lifetimes play the role of the lease: the preferred lifetime says how long the address can be used for new connections, and the valid lifetime says when it disappears. Each new RA that repeats the prefix refreshes both.
SLAAC requires a prefix length of exactly /64. If your design needs another length, SLAAC does not work on that segment.
The trade-off is control. A SLAAC network has no central table of which device holds which address. Temporary privacy addresses make this worse, because one host can have several addresses that change over days. Operators must collect that information from router neighbor tables or switch logs.
DHCPv6
DHCPv6 (RFC 8415) brings back the server and the lease. Its main differences from DHCPv4:
- The client uses UDP port 546 and the server and relay agents use UDP port 547. These are not the 68 and 67 of DHCPv4.
- The client sends to the multicast address
ff02::1:2(AllDHCPRelayAgentsand_Servers), from its link-local address. It does not need a global address. - Clients are identified by a DUID (DHCP Unique Identifier), not by MAC address. A DUID is a stable ID the client generates once and keeps. A reservation on the server therefore refers to a DUID.
- The server can assign non-address data. With prefix delegation (IA_PD), a home router asks its provider for a whole prefix, such as a /56, to split among its own subnets.
- The server cannot send a default gateway, as noted above.
The four-message exchange
The stateful exchange mirrors DORA but uses different names:
| DHCPv6 message | DHCPv4 counterpart |
|---|---|
| Solicit | Discover |
| Advertise | Offer |
| Request | Request |
| Reply | Acknowledge |
| Renew, Rebind | Renewal at T1, rebinding at T2 |
| Release, Decline | Release, Decline |
| Information-Request | Inform |
DHCPv6 also has a Rapid Commit option. The client sends Solicit with the option, and a server that supports it replies directly with Reply. This reduces the exchange to two messages.
The lease timers carry over. DHCPv6 returns T1 and T2 inside each address binding (IA_NA, "identity association for non-temporary addresses"). Typical servers set T1 to 50% and T2 to 80% of the preferred lifetime, but a server may choose other values.
Choosing a mode with the M and O flags
The router decides what the host should do by setting two flags in each RA:
| A flag | M flag | O flag | Result |
|---|---|---|---|
| 1 | 0 | 0 | SLAAC only. DNS comes from RDNSS in the RA. |
| 1 | 0 | 1 | Stateless DHCPv6. The address comes from SLAAC. The host uses DHCPv6 (Information-Request) for DNS and other options. |
| 0 | 1 | 1 | Stateful DHCPv6. The address and options come from the server. |
| 1 | 1 | 1 | SLAAC and DHCPv6 addresses together. The host may have both. |
Not every client follows the flags. Android, for example, does not implement DHCPv6 address assignment. A network that must support Android phones therefore needs SLAAC, even when you want DHCPv6 for other clients.
A sample configuration
dnsmasq can act as the router advertiser and as the DHCPv6 server. This configuration shows the two common modes. Use only one dhcp-range line for IPv6 per interface.
# /etc/dnsmasq.conf (IPv6 part only)
interface=eth0
enable-ra
# Mode 1: SLAAC only, with DNS announced in the RA
dhcp-range=2001:db8:1::, ra-only
dhcp-option=option6:dns-server,[2001:db8:1::53]
# Mode 2 (use instead of mode 1): SLAAC for addresses,
# stateless DHCPv6 for DNS and other options
# dhcp-range=2001:db8:1::, ra-statelessFor stateful DHCPv6, replace the range with an actual pool, for example dhcp-range=2001:db8:1::100,2001:db8:1::1ff,64,12h.
Inspecting IPv6 configuration
To see addresses and their lifetimes on Linux, run ip -6 addr show dev eth0. The output shows preferred_lft and valid_lft, and flags such as temporary and dynamic. To watch the traffic, capture Router Advertisements and DHCPv6 separately:
# Router Advertisements (ICMPv6 type 134)
sudo tcpdump -n -i eth0 -vv 'icmp6 and ip6[40] == 134'
# DHCPv6 messages (client port 546, server port 547)
sudo tcpdump -n -i eth0 -vv 'udp and (port 546 or port 547)'Common problems follow the same pattern as DHCPv4 troubleshooting:
- No global address, only
fe80::. No RA arrived. Check that the router has IPv6 routing enabled and that a switch feature is not blocking RAs. - Address but no default route. The RA has a router lifetime of 0, or the network uses DHCPv6 without RAs.
- DHCPv6 messages never reach the server. Check that the server listens on
ff02::1:2, and that a relay on the router forwards to it. Relays work as in IPv4, but they are configured with the server's IPv6 address. - Rogue RAs. Any host on the link can send an RA and become a default router for the others. It is the IPv6 counterpart of a rogue DHCP server, and the switch feature that blocks it is RA Guard. DHCPv6 has its own DHCPv6 Guard and snooping features.
Exercise
A host on a network has a link-local address and a global address, but it cannot reach any off-link destination. The network uses DHCPv6 for addresses and options, and the administrator turned off Router Advertisements. What is missing, and which mechanism has to provide it?
Show answer
The default route. DHCPv6 has no option that supplies a default gateway, so the host does not know a router. A router must send RAs with a nonzero router lifetime. The administrator can keep the M flag set so that the host still gets its address from DHCPv6.
Exercise
An RA has A=1, M=0 and O=1. Where does the host get its address, and where does it get its DNS server?
Show answer
The address comes from SLAAC, built from the advertised /64 prefix. The DNS server comes from stateless DHCPv6 (an Information-Request to the server), or from an RDNSS option in the RA if the router sends one.