Sub topic 15
DHCPv6 and when to use it
This chapter assumes you know how SLAAC and Router Advertisements work, that a /64 is the standard subnet size, and that you can read IPv6 prefixes. It also assumes you know what a DHCP server does in IPv4.
What DHCPv6 adds
SLAAC lets a host build its own address from a prefix in a Router Advertisement (RA). That prefix is all SLAAC provides. A host also needs DNS servers, and some networks need to control who gets which address. DHCPv6 is the Dynamic Host Configuration Protocol for IPv6, and it fills these gaps. Clients send messages to the multicast address ff02::1:2 on UDP port 547. Servers and relays answer on UDP port 546.
DHCPv6 has two modes:
- Stateless DHCPv6 hands out only extra settings, such as DNS servers and a domain search list. The host still builds its address with SLAAC. The server keeps no per-client record.
- Stateful DHCPv6 assigns addresses and tracks leases, much like DHCPv4. The server records which client holds which address.
How the router chooses the mode
The router signals the mode with two flags in its Router Advertisement.
| Flag | Name | Meaning |
|---|---|---|
| A (in the prefix option) | Autonomous | The host may build an address with SLAAC |
| O | Other configuration | Ask DHCPv6 for settings other than the address |
| M | Managed | Ask DHCPv6 for an address |
A common stateless setup sets A=1 and O=1. A fully managed setup sets M=1 and often A=0 so hosts do not also self-configure.
In stateful mode the exchange is Solicit, Advertise, Request, Reply. A stateless client uses a shorter Information-Request and Reply pair.
Differences from DHCPv4
- The default gateway never comes from DHCPv6. Hosts learn it from the router's RA, so DHCPv6 cannot hand out a gateway.
- Clients are identified by a DHCP Unique Identifier (DUID), not by MAC address.
- A DHCPv6 address has no prefix length. The host gets the length from the RA prefix option.
- DHCPv6 can delegate a whole prefix to a router (prefix delegation). ISPs use this to give a home router a /56 or /48.
When to use which
- Use SLAAC alone when hosts need only an address and your RAs can carry DNS information (the RDNSS option).
- Use SLAAC plus stateless DHCPv6 when you want central control of DNS settings without lease tracking.
- Use stateful DHCPv6 when policy or auditing requires you to know which client held which address, or when you must assign fixed addresses.
You can check what a Linux host received:
ip -6 addr show
ip -6 route show defaultAddresses marked dynamic with a lease time came from SLAAC or DHCPv6. The default route shows the router that sent the RA.
Exercise
A network sets the A flag and the O flag in its Router Advertisements, with M clear. Where does a host get its address, and where does it get its DNS server list?
Show answer
It builds its address with SLAAC, because A is set. It gets its DNS servers from DHCPv6 (stateless mode), because O is set and M is clear.