DHCPv6: stateful, stateless and prefix delegation
Describe the DHCPv6 message exchanges, ports, multicast addresses and identifiers (DUID, IAID). Distinguish stateful (IA_NA), stateless (Information-request) and prefix delegation (IA_PD) service, and how RA flags select them. Explain relay agents and calculate renewal timers and PD numbering. Delegate a /56 to a CPE through a relay with Kea and use the RFC 6603 Prefix Exclude option.
Take the quiz · pass mark 70% · 10 questions
Explanation
DHCPv6 is defined in RFC 9915, an Internet Standard (STD 102) published in January 2026 that replaced the earlier DHCPv6 specification. It does three jobs:
- Stateful address assignment: the server leases addresses (Identity Association for Non-temporary Addresses, IA_NA).
- Stateless configuration: no addresses, only options such as DNS servers (the Information-request exchange).
- Prefix delegation: the server leases whole prefixes (IA_PD) to a requesting router, typically a /56 to a home CPE or a /48 to a business router. This is how almost every ISP gives IPv6 to its customers.
RFC 9915 also obsoletes temporary address assignment (IA_TA): privacy addresses come from SLAAC (L3.04).
What DHCPv6 does not do
There is no default gateway option in DHCPv6. Hosts always learn their default router from RAs (L3.02). There is also no subnet mask: addresses from IA_NA are installed as /128, and the on-link prefix comes from the RA's PIO (or is absent, in which case traffic goes via the router). A DHCPv6-only network without RAs does not work.
Ports, addresses and messages
- Clients use UDP port 546. Servers and relays listen on 547.
- Clients send to
ff02::1:2(All_DHCP_Relay_Agents_and_Servers), from their link-local address. - Relays can forward to servers at
ff05::1:3(All_DHCP_Servers, site scope) or, more commonly, to a configured unicast address.
| Type | Message | Purpose |
|---|---|---|
| 1 | Solicit | Client looks for servers |
| 2 | Advertise | Server offers |
| 3 | Request | Client asks the chosen server for leases |
| 4 | Confirm | Client checks its addresses are still on-link after moving |
| 5 / 6 | Renew / Rebind | Extend leases: Renew to the original server at T1, Rebind to any server at T2 |
| 7 | Reply | Server's answer to most messages |
| 8 / 9 | Release / Decline | Give back leases, or report a duplicate found by DAD |
| 10 | Reconfigure | Server asks the client to Renew or Information-request now |
| 11 | Information-request | Stateless: options only |
| 12 / 13 | Relay-forw / Relay-repl | Relay encapsulation |
The normal four-message exchange is Solicit, Advertise, Request, Reply (SARR). With the Rapid Commit option, client and server use two messages: Solicit with Rapid Commit, then Reply. Stateless service is just Information-request, Reply.
Identifiers
- DUID (DHCP Unique Identifier) identifies the client or server device. Types: 1 DUID-LLT (link-layer address plus time), 2 DUID-EN (enterprise number), 3 DUID-LL (link-layer address), 4 DUID-UUID. The server binds leases to the DUID, not to the MAC address. This surprises IPv4 administrators: a DHCPv4 MAC reservation does not carry over, and cloned VMs that share a DUID get the same lease. systemd-networkd derives its DUID from
/etc/machine-idby default, so clone VMs only after resetting it. - IAID identifies one IA within a client, usually one per interface. A CPE typically uses one IAID for IA_NA on the WAN and another for IA_PD.
Timers
Each IA carries T1 and T2. At T1 the client sends Renew to the server that gave the lease. If there is no answer by T2, it sends Rebind to any server. RFC 9915 recommends T1 = 0.5 and T2 = 0.8 times the shortest preferred lifetime in the IA. If the lifetimes run out, the addresses or prefixes are removed.
RA flags select the behaviour
| RA flags | Typical host behaviour |
|---|---|
| M=0, O=0 | SLAAC only, DNS from RDNSS |
| M=0, O=1 | SLAAC addresses, DNS and other options from DHCPv6 Information-request |
| M=1 | Addresses from DHCPv6 (IA_NA); O is implied |
| PIO with A=0, M=1 | DHCPv6 addresses only, no SLAAC |
The flags are hints, and clients differ. Android does not implement DHCPv6 address assignment (IA_NA), so an M=1, A=0 network leaves Android devices without global addresses. Many CPEs request IA_PD regardless of flags. RFC 8504 says hosts should implement DHCPv6 address configuration and, if they implement DHCPv6, must support the DNS options. Design LANs so every client type you support has a working path (usually SLAAC plus RDNSS, with DHCPv6 added where needed).
Relays
When the server is not on the link (normal in an ISP or enterprise), a relay agent on the router receives the client's multicast and wraps it in a Relay-forw message with:
- link-address: a global address of the interface the client is on. The server uses this to choose the subnet and pools.
- peer-address: the client's link-local address.
- optional Interface-ID (option 18) and other relay options, such as the Remote-ID.
Relays can be chained. Each adds a layer, and messages are dropped after 8 hops (HOP_COUNT_LIMIT).
Prefix delegation
In PD, the requesting router (the CPE) asks the delegating router (or a DHCPv6 server behind a relay) for a prefix:
Drawing diagram…
Two points cause most PD problems:
- Someone must route the delegated prefix to the CPE. Delegating routers that run the DHCPv6 server (for example a MikroTik BNG) install the route themselves. A plain relay and a remote server do not, unless the relay snoops the replies or the server pushes routes through a hook or RADIUS. Without the route, the CPE has a prefix but no return traffic.
- The CPE must use the prefix correctly. RFC 7084 (CE router requirements) says the CPE assigns /64s from the delegated prefix to its LAN interfaces, and must not advertise the delegated prefix on the WAN.
Prefix Exclude (RFC 6603)
Sometimes the ISP numbers the CPE's WAN link from the customer's own delegated prefix (to save address space or simplify routing). The delegating router then includes OPTION_PD_EXCLUDE (67) inside the IA Prefix option, telling the CPE which part of the delegation it must not use on its LANs. The option carries the excluded prefix length and only the bits after the delegated length (the subnet ID), padded to whole octets. Its option-len is 1 + the number of subnet ID octets. The CPE must request the option in its Option Request option, and support on CPEs is uneven, so confirm before relying on it.
Newer extensions
- RFC 9663 describes delegating a prefix (for example a /64) to each host on a LAN with DHCPv6-PD, so the host can run containers or tethering without NAT. RFC 9762 adds the PIO P flag to signal that this is preferred (L3.02).
- RFC 9686 lets clients register self-generated (SLAAC or static) addresses with the DHCPv6 server, for logging and accountability, using ADDR-REG-INFORM messages.
ictNetworks scenario
Each MikroTik BNG in the residential plan has a /40 (for example 3fff:a00:8200::/40) and delegates one /56 per home from it, such as 3fff:a00:8212:3400::/56. On RouterOS v7:
/ipv6 pool add name=pd-bng-8200 prefix=3fff:a00:8200::/40 prefix-length=56
/ipv6 dhcp-server add name=pd-access interface=vlan-access prefix-pool=pd-bng-8200 \
lease-time=1d
The BNG installs a route for each delegated /56 towards the subscriber.
Worked examples
Example 1: T1 and T2
A server offers an IA_PD with preferred lifetime 3,600 s and valid lifetime 7,200 s. With the recommended values, T1 = 0.5 × 3,600 = 1,800 s and T2 = 0.8 × 3,600 = 2,880 s.
Example 2: How many /56s in a PD pool?
The lab PD pool 2001:db8:1100::/40 with delegated length 56 holds 2^(56 − 40) = 65,536 delegations.
Example 3: Which delegation is the home's?
The home prefix 3fff:a00:8212:3400::/56 sits in the BNG's 3fff:a00:8200::/40. The bits between /40 and /56 are the hex digits 12 34, so it is delegation number 0x1234 = 4,660 (counting from 0).
Example 4: Numbering the LAN
The CPE's delegated prefix is 2001:db8:1100:1200::/56. With subnet ID 1 for the main LAN (dhcpcd ia_pd 2 eth1/1/64), the LAN prefix is 2001:db8:1100:1201::/64, and subnet ID 0xff gives 2001:db8:1100:12ff::/64.
Example 5: Prefix Exclude option length
Delegated /56, excluded /64: the subnet ID is 64 − 56 = 8 bits = 1 octet, so option-len = 1 + 1 = 2. For a delegated /48 with an excluded /64 the subnet ID is 16 bits, so option-len = 3.
Lab
Goal: Delegate a /56 to a CPE through a relay, number its LAN, and make return traffic work.
You need: Containerlab (or namespaces) with four nodes: kea (Kea DHCPv6 server), bng (a Linux router running dhcrelay from the isc-dhcp-relay package), cpe (Linux with dhcpcd) and lanhost. FRR does not include a DHCPv6 relay, so use a Debian-based router image for bng, or add the relay package to your FRR image. ISC DHCP, including dhcrelay, is end of life but still packaged by major distributions. Any relay that supports DHCPv6, such as dnsmasq's --dhcp-relay, also works.
Addressing (ISP-A lab block)
| Link | Prefix | Addresses |
|---|---|---|
| Server LAN | 2001:db8:1000:5::/64 | kea ::547, bng ::1 |
| Access link | 2001:db8:1000:2001::/64 | bng ::1 |
| PD pool | 2001:db8:1100::/40, delegated length 56 |
Step 1: Kea
{
"Dhcp6": {
"interfaces-config": { "interfaces": [ "eth1/2001:db8:1000:5::547" ] },
"lease-database": { "type": "memfile", "persist": true, "name": "/var/lib/kea/kea-leases6.csv" },
"preferred-lifetime": 3600, "valid-lifetime": 7200,
"renew-timer": 1800, "rebind-timer": 2880,
"subnet6": [ {
"id": 1,
"subnet": "2001:db8:1000:2001::/64",
"pools": [ { "pool": "2001:db8:1000:2001::1000-2001:db8:1000:2001::1fff" } ],
"pd-pools": [ { "prefix": "2001:db8:1100::", "prefix-len": 40, "delegated-len": 56 } ],
"option-data": [ { "name": "dns-servers", "data": "2001:db8:1000:5::53" } ]
} ]
}
}
The eth1/address form makes Kea listen for unicast traffic from the relay, which it does not do by default. The subnet matches the relay's link-address.
Step 2: Relay and RAs on the BNG
sysctl -w net.ipv6.conf.all.forwarding=1
dhcrelay -6 -d -l eth2 -u 2001:db8:1000:5::547%eth1
Run radvd on eth2 (the access link) with AdvManagedFlag on and a PIO for 2001:db8:1000:2001::/64 with AdvAutonomous off.
Step 3: CPE
/etc/dhcpcd.conf on the CPE (eth1 WAN, eth2 LAN):
ipv6only
noipv4ll
interface eth1
ipv6rs
ia_na 1
ia_pd 2 eth2/1/64
dhcpcd does not send RAs, so also run radvd on the CPE's eth2 with prefix ::/64 { AdvOnLink on; AdvAutonomous on; };, which advertises whatever /64 dhcpcd assigned to that interface. Enable forwarding on the CPE. Linux then ignores RAs on the WAN unless accept_ra=2; dhcpcd handles RAs itself, but set accept_ra=2 on eth1 if you see no default route.
Start dhcpcd, then capture on the access link and on the server LAN. Identify Solicit, Advertise, Request and Reply, and the Relay-forw link-address and peer-address. Record the delegated prefix and the LAN prefix on eth2.
Step 4: Make it route
From lanhost (SLAAC from the CPE's RAs), ping 2001:db8:1000:5::547. It fails. Explain why, then add the missing route on the BNG:
ip -6 route add 2001:db8:1100:XX00::/56 via <cpe-wan-link-local> dev eth2
Step 5: Renewal and Prefix Exclude (optional)
Watch the CPE renew at T1. Then add "excluded-prefix" and "excluded-prefix-len" to the pd-pool (see the Kea documentation) and request option 67 from the CPE (option lines in dhcpcd, if your version supports it), and decode the option in Wireshark.
What to submit
Configurations, the annotated capture (relay fields, IA_PD contents, T1/T2), the CPE's prefix and LAN addresses, the route fix with explanation, and the Kea lease file entries.
Summary
- RFC 9915 is the current DHCPv6 specification. Clients use port 546 and
ff02::1:2, servers and relays port 547, andff05::1:3reaches all servers. IA_TA is obsolete. - There is no gateway option: RAs are always needed. The M and O flags are hints, and Android does not do IA_NA.
- Leases are tied to the DUID and IAID, not the MAC. T1 = 0.5 and T2 = 0.8 times the shortest preferred lifetime.
- Relays add link-address, peer-address and options. The server picks the subnet from the link-address.
- With PD, someone must route the delegated prefix to the CPE. RFC 6603 Prefix Exclude marks part of a delegation as reserved for the WAN link.
- Next lesson (L3.04): which source address a host picks, and how privacy addresses work.
Quiz imported · 10 questions · pass mark 70%. Lab questions are not auto-marked.