Skip to content

IPv6 address autoconfiguration: SLAAC, DHCPv6, and how Linux decides

Learn how a Linux server gets its IPv6 address through SLAAC or DHCPv6, what the router's M and O flags decide, and which commands show what the host really received.

This guide shows you how a Linux server gets its IPv6 address, and how to check what it actually received. You will need it the day a machine has no IPv6 address, carries two at once, or loses its default route. The answer sits in the RA (Router Advertisement), the message a router sends to announce itself to machines on the network. When the RA’s M flag (Managed) is off, the host builds its own address from the advertised prefix, which is called SLAAC (stateless address autoconfiguration). When the M flag is on, the address comes from a DHCPv6 server, the IPv6 version of DHCP that hands out addresses from a pool. A second flag, O (OtherConfig), tells the host whether to fetch DNS settings from DHCPv6 as well.

How to verify

Inspect what the host received and how it decided:

ip -6 addr show
ip -6 route show
sysctl net.ipv6.conf.eth0.accept_ra
sysctl net.ipv6.conf.eth0.autoconf
rdisc6 eth0
dhclient -6 -d eth0
journalctl -u systemd-networkd | grep -i ra

rdisc6 (from the ndisc6 package) sends a Router Solicitation and prints the RA reply with all flags decoded — by far the fastest way to see what the upstream router is advertising.

What’s happening

IPv6 hosts begin by sending an ICMPv6 Router Solicitation. Routers respond with a Router Advertisement that carries:

  • One or more Prefix Information options, each with the A (autonomous) flag — if A is set, the host can use this prefix for SLAAC.
  • The M flag (Managed) — if set, the host must use stateful DHCPv6 to obtain an address.
  • The O flag (OtherConfig) — if set, the host should use stateless DHCPv6 for non-address config (DNS, NTP).
  • Lifetimes, MTU, source link-layer address.

The host’s resulting behaviour depends on the flag combination:

  • M=0, O=0 — pure SLAAC. Address derived from the prefix plus an interface identifier (modified EUI-64 or RFC 7217 stable privacy hash). DNS via RA option (RFC 8106) or static.
  • M=0, O=1 — SLAAC for the address, DHCPv6 stateless for DNS/NTP.
  • M=1, O=1 — stateful DHCPv6 for the address and DNS. SLAAC may still happen alongside if any prefix has A=1.
  • M=1, O=0 — rare and broken; M=1 implies the client wants config from DHCPv6 but the router says O=0. Most clients fetch DNS anyway.

Linux maintains sysctls per interface: net.ipv6.conf.eth0.accept_ra (1=accept, 2=accept-even-when-forwarding), net.ipv6.conf.eth0.autoconf (1=use prefix-info for SLAAC), net.ipv6.conf.eth0.accept_ra_pinfo (process prefix-info option), and accept_ra_rt_info_max_plen (accept route info options up to this prefix length).

The procedure

  1. Start by verifying the RA the upstream is sending. Without this, every other step is guesswork.

    rdisc6 eth0
    # Look for:
    #   Stateful address conf.    : No   (M flag)
    #   Stateful other conf.      : Yes  (O flag)
    #   Prefix : 2001:db8:1::/64  Valid time:  86400s  ...
    #   Autonomous address conf.: Yes  (A flag in prefix-info)
  2. Pure SLAAC server config (M=0, O=0). systemd-networkd defaults are correct:

    # /etc/systemd/network/10-eth0.network
    [Match]
    Name=eth0
    
    [Network]
    DHCP=no
    IPv6AcceptRA=yes

    Confirm:

    ip -6 addr show dev eth0 | grep mngtmpaddr
    ip -6 route show default

    Each SLAAC address shows mngtmpaddr if it came from a prefix lifetime; valid_lft and preferred_lft show the lifetimes counting down.

  3. Hybrid — SLAAC for address, DHCPv6 for DNS (M=0, O=1). Enable DHCPv6 stateless:

    [Network]
    DHCP=ipv6
    IPv6AcceptRA=yes

    Or with dhclient on systems still using it:

    dhclient -6 -S eth0   # -S = stateless, request other config only
  4. Stateful DHCPv6 (M=1). The router does not assign prefixes via SLAAC; the DHCPv6 server hands out a /128 from a pool plus DNS, search domain, NTP servers. systemd-networkd:

    [Network]
    DHCP=ipv6
    IPv6AcceptRA=yes

    The same DHCP=ipv6 triggers stateful when the RA’s M flag is set. Verify the lease:

    networkctl status eth0
    journalctl -u systemd-networkd | grep -E '(DHCPv6|RA)'
  5. For a server that should not autoconfigure, disable RA processing entirely:

    sysctl -w net.ipv6.conf.eth0.accept_ra=0
    sysctl -w net.ipv6.conf.eth0.autoconf=0

    Then set the address and route statically:

    ip -6 addr add 2001:db8:1::100/64 dev eth0
    ip -6 route add default via fe80::1 dev eth0
  6. Privacy addresses. RFC 4941 gives temporary outgoing addresses on top of the stable SLAAC address. Disable on servers to avoid surprising reverse-DNS mismatches:

    sysctl -w net.ipv6.conf.eth0.use_tempaddr=0

    Or set to 2 to make the temporary address the preferred outgoing one (the desktop default).

Operational notes

  • accept_ra is overridden by forwarding=1 on routers. If net.ipv6.conf.all.forwarding=1, RAs are not processed unless accept_ra=2. This catches K8s nodes and edge routers regularly.
  • Multiple RAs from different routers cause flap. Two routers advertising different prefixes on the same segment cause hosts to pick one (usually highest preference or shortest lifetime); the loser’s prefix gets removed and re-added on the next RA cycle.
  • RA lifetime affects route stability. A short router lifetime (60 seconds) means the default route disappears if the router stops advertising for 60 seconds — useful for HA failover, painful for testing.
  • DHCPv6 cannot provide a default route by itself; the default route always comes from RA. M=1 without RAs results in no IPv6 default route.
  • Static SLAAC prefix only works if A=1 in the RA’s prefix-info. If the upstream advertises A=0, the prefix is informational only, and the host will not derive an address from it.

In the engagements we run, the IPv6 deployment baseline is M=0/O=1 — SLAAC for addressing, DHCPv6 stateless for DNS. It keeps the router as the source of truth for the address space and lets DNS evolve without touching every host. Stateful DHCPv6 is reserved for tenant environments that need predictable addresses. The verification commands and the systemd-networkd templates above ship in the standard host bring-up role used by the managed-operations practice.