DHCPv6 vs SLAAC: How IPv6 Addresses Are Assigned

An IPv6 host can obtain an address automatically in two ways: DHCPv6 and SLAAC. With SLAAC (stateless address autoconfiguration, RFC 4862), the host learns the link's prefix from the router advertisements (RAs) that routers send, creates its own interface ID and assembles the address. No server keeps track of which host uses which address, which is why it is called "stateless". With DHCPv6 (RFC 8415), as with DHCP for IPv4, a server chooses an address, leases it for a limited time and keeps a record of it. Either way, the default gateway is learned from RAs. There is also a combination called stateless DHCPv6, in which the address is formed by SLAAC and only other information, such as the DNS server address, comes from DHCPv6.

AspectDHCPv6SLAAC
Who decides the addressThe DHCPv6 server, which picks one from the range it manages and leases it for a limited timeThe host itself, which combines the prefix learned from RAs with an interface ID it creates
StateStateful: the server records which address it leased to which hostStateless: no server records address assignments
What is requiredA DHCPv6 server (and a relay agent if it is on another link), plus RAs telling hosts to use DHCPv6A router sending RAs that announce the prefix
Messages usedUDP (port 546 for clients, 547 for servers and relay agents); the basic exchange is Solicit, Advertise, Request and ReplyRouter Solicitation (RS) and Router Advertisement (RA) from ICMPv6 Neighbor Discovery (NDP)
Default gatewayNot provided by DHCPv6; the link-local address of the router that sent the RA is usedThe link-local address of the router that sent the RA is used
DNS server addressProvided in a DHCPv6 optionProvided in an RA option (RDNSS) or by stateless DHCPv6
Interface ID (lower 64 bits)Chosen by the serverEUI-64 format derived from the MAC address, or a value based on random numbers; for privacy, many operating systems use random-based values
Prefix length and delegationAssigns addresses one at a time, so it also works with prefixes other than /64; it can also delegate whole prefixes to routers (DHCPv6-PD)Generally assumes a /64 prefix; cannot delegate prefixes
How easy it is to track addressesThe server's records show which host uses which address; clients are identified by an identifier called a DUIDThere are no server records, so finding a host's address means checking, for example, the router's neighbor cache

Figures are typical orders of magnitude and vary by process generation and product.

When to use which

DHCPv6
Enterprise networks that want to manage and record which address was assigned to which host, and provider lines that hand out prefixes to routers (DHCPv6-PD). Some host operating systems cannot obtain an address via DHCPv6, so check support.
SLAAC
When addresses should be handed out simply without running a server, as in homes and many LANs. DNS server information is supplied by the RA RDNSS option or by stateless DHCPv6.

FAQ

Are router advertisements (RAs) still needed when using DHCPv6?

Yes. DHCPv6 has no way to provide a default gateway; hosts use the link-local address of the router that sent the RA as their default gateway. RAs also tell hosts, with the M flag (Managed), to get addresses from DHCPv6, and with the O flag (Other), to get other information such as DNS servers from DHCPv6.

What is stateless DHCPv6?

A setup in which hosts form their own addresses with SLAAC and get only non-address information, such as DNS server addresses, from a DHCPv6 server. The server does not record which address belongs to which host, hence "stateless". Hosts are told to use it by an RA with the M flag set to 0 and the O flag set to 1.

How does SLAAC avoid duplicate addresses?

Before using an address it has formed, the host uses Neighbor Discovery to check that no other device is using the same address. This is called duplicate address detection (DAD). An address found to be a duplicate is not used. Addresses obtained via DHCPv6 are checked the same way.

Can a host be tracked from its SLAAC address?

With an EUI-64 interface ID derived from the MAC address, the lower 64 bits are the same on every network, which makes the host easier to track. For that reason, interface IDs that look random and differ per network (RFC 7217) and temporary addresses that change over time (RFC 8981) are used.

Check your understanding

In IPv6, which range holds link-local addresses, which are used only within the same link and are always configured automatically on every interface that uses IPv6?

  1. A2001:db8::/32
  2. Bff00::/8
  3. Cfe80::/10
Show answer and explanation

Answer: C. fe80::/10

Link-local addresses are in the range fe80::/10; they are not forwarded beyond a router and are used only for communication within the same link. They are used for exchanges such as Neighbor Discovery (NDP) and router advertisements, and a host's default gateway is also normally the router's link-local address. 2001:db8::/32 is a range reserved for examples in explanations and documents (documentation addresses). ff00::/8 holds multicast addresses; IPv6 uses multicast instead of broadcast.

In IPv6 SLAAC (stateless address autoconfiguration), how does a host create a global unicast address?

  1. AIt queries a DHCPv6 server and leases a 128-bit address managed by the server for a set period
  2. BIt combines the /64 prefix in the router advertisement (RA) sent by a router with an interface ID (the lower 64 bits) it creates itself, and uses the address after checking that no other device has the same address
  3. CIt puts its own IPv4 address as it is into the lower 32 bits and fills the upper bits with a value starting with fe80
Show answer and explanation

Answer: B. It combines the /64 prefix in the router advertisement (RA) sent by a router with an interface ID (the lower 64 bits) it creates itself, and uses the address after checking that no other device has the same address

With SLAAC, a host learns the prefix of its link (normally a /64) from the router advertisements (RAs) that routers send periodically or on request. It combines this with an interface ID, either in the EUI-64 format derived from its MAC address or based on a random value, to form an address. Before using it, the host uses Neighbor Discovery to check that no other device is using the same address (duplicate address detection, DAD). The link-local address of the router that sent the RA becomes the default gateway, and because no server manages the address assignments, it is called "stateless." DNS server addresses are provided by an RA option or by stateless DHCPv6.

An interface with MAC address 00-1A-2B-3C-4D-5E creates an address with SLAAC from the prefix 2001:db8:1:1::/64 and an interface ID in the EUI-64 format. Which address results?

  1. A2001:db8:1:1:21a:2bff:fe3c:4d5e
  2. B2001:db8:1:1:1a:2bff:fe3c:4d5e
  3. C2001:db8:1:1:21a:2bfe:ff3c:4d5e
Show answer and explanation

Answer: A. 2001:db8:1:1:21a:2bff:fe3c:4d5e

In the EUI-64 format, the 48-bit MAC address is split into its upper 24 bits and lower 24 bits, and FF-FE is inserted between them to make 64 bits. Inserting it between 00-1A-2B and 3C-4D-5E gives 00-1A-2B-FF-FE-3C-4D-5E. In addition, the second-lowest bit of the first byte (the U/L bit) is inverted, so 00 becomes 02, giving 02-1A-2B-FF-FE-3C-4D-5E. Grouping this into 16-bit pieces and dropping leading zeros in each gives 21a:2bff:fe3c:4d5e, and with the prefix the address is 2001:db8:1:1:21a:2bff:fe3c:4d5e. Because an address that reveals the MAC address makes the host easier to track, most current operating systems use interface IDs based on random values.

  1. Hosts in VLAN 20 (192.168.20.0/24) are to get addresses from a DHCP server, 10.0.0.5, on another network. A DHCP relay agent is therefore configured on the L3 switch interface 192.168.20.1, which is VLAN 20's default gateway. Which statement correctly describes what the relay agent does?
  2. When a device obtains an IP address with DHCP, what is the correct order of messages?

Practice Network Design and Operations questions

Key terms explained

SLAAC (stateless address autoconfiguration)
An IPv6 mechanism in which a host learns the network prefix (normally a /64) from the router advertisements (RAs) sent by routers and combines it with an interface ID it creates itself to configure an address automatically. The interface ID is either in the EUI-64 format derived from the MAC address or based on a random value to prevent tracking. Before using the address, the host checks with duplicate address detection (DAD) that no other device has it.
DHCP
Dynamic Host Configuration Protocol. A protocol that automatically assigns devices joining a network an IP address, subnet mask, default gateway, DNS servers and other settings for a limited time.
IPv6
Version 6 of IP. It expands addresses to 128 bits, written as eight groups of 16 bits in hexadecimal, such as 2001:db8::1. The header is a simpler fixed 40 bytes, and routers along the path do not fragment packets. It is not compatible with IPv4, so the transition uses dual stack, which runs both at once, and translation mechanisms.
Default gateway
The router to which a host hands packets for destinations on other networks. The host uses its subnet mask to decide whether a destination is on the same network, and sends to this router if not.
DNS (Domain Name System)
A system, managed in a distributed way by servers around the world, that maps domain names such as www.example.com to the IP addresses used for communication.
MAC address
The 48-bit address used in Ethernet and wireless LAN to identify devices within the same network. The upper 24 bits identify the manufacturer, and it is assigned to each interface at manufacture.
ICMP (Internet Control Message Protocol)
A protocol for reporting errors and conditions in IP communication. It tells the sender, for example, that a destination cannot be reached (Destination Unreachable) or that a packet's TTL reached 0 (Time Exceeded). ping uses echo requests and echo replies to check reachability and measure RTT, and traceroute uses Time Exceeded messages to trace a path. In IPv6, ICMPv6 also handles neighbor discovery and more.

Related comparisons