Lab: SLAAC and DHCPv6 side by side, watched in Wireshark
Run an isolated Linux namespace pair with dnsmasq and dhclient -6 to test SLAAC (ra-only), stateless DHCPv6 (O=1) and stateful DHCPv6 (M=1, O=1, A=0), compare /64 SLAAC vs /128 DHCPv6 addresses and inspect DAD, RS, RA and DHCPv6 frames in tcpdump or Wireshark.
Contentsand lesson path
On this page
- Goal and setup
- Step 1: Start dnsmasq in SLAAC-only mode and inspect host addresses
- Step 2: Read DAD, Router Solicitation and Router Advertisement frames
- Step 3: Run stateless (O=1) and stateful (M=1, A=0) DHCPv6 clients and clean up
- Check your understanding
- Apply it
- Review prompt
Lessons of IPv6 Addressing & Operation
- IPv6 addresses without fear: notation, scopes and types Concept · 20 min
- Neighbor Discovery replaces ARP: NS/NA, RS/RA and duplicate address detection Concept · 20 min
- Lab: SLAAC and DHCPv6 side by side, watched in Wireshark Lab · 30 min
- Worked example: a /48 site plan and the ICMPv6 you must allow Worked example · 25 min
- Living with IPv4: dual stack, NAT64/DNS64 and 464XLAT Concept · 15 min
- Check: IPv6 addressing and troubleshooting scenarios Knowledge check · 8 questions
What you will learn
- Explain Neighbor Discovery (NS/NA, RS/RA, duplicate address detection) and configure hosts with SLAAC and DHCPv6, including the flags in router advertisements.
01. Goal and setup
Router Advertisement flags (A, M, O) and DHCPv6 modes become concrete once you watch a host boot onto a link and inspect the packets. In this lab you build a two-namespace topology—one isolated router namespace running dnsmasq, connected by a virtual Ethernet (veth) cable to a host namespace ($H)—and compare pure SLAAC, stateless DHCPv6 (O = 1), and stateful DHCPv6 (M = 1, O = 1, A = 0) using real dhclient -6 and tcpdump captures.
Step 0 (isolated environment): Never run ip addr add or dnsmasq directly in your host's default network namespace, because that changes your workstation routing table. Start an isolated user+network namespace first (unshare -c -n --keep-caps bash on Linux distributions that allow unprivileged user namespaces, or sudo unshare -n bash inside a disposable lab VM). On this lab machine (iproute2-5.15.0, dnsmasq 2.90, tcpdump 4.99.1), all commands below run inside unshare -c -n --keep-caps bash using RFC 3849 prefix 2001:db8:10::/64. Because this headless environment has no GUI, we decode saved .pcap files with tcpdump -r and provide the equivalent Wireshark display filters to open those same .pcap files in Wireshark on your desktop. Note also that ISC dhclient (4.4.1) reached end-of-maintenance in 2022 and newer distributions increasingly omit it by default in favour of dhcpcd or systemd-networkd (networkctl); it remains packaged here for explicit Info-Request and Solicit tracing.
[host ns ($H)] [router ns (isolated shell)]
h-v6 (02:00:00:00:60:10) <--- veth ---> r-v6 (02:00:00:00:60:01)
SLAAC / dhclient -6 2001:db8:10::1/64 + dnsmasq02. Step 1: Start dnsmasq in SLAAC-only mode and inspect host addresses
Inside your isolated router shell, create a scratch folder (avoid /tmp if shared; use a dedicated working directory such as ~/ipv6-lab03). Spawn $H with sleep infinity so the host namespace stays alive until you clean up, wire the veth pair with deterministic MAC addresses (...:60:10 and ...:60:01), and start dnsmasq in ra-only mode with an explicit 1800-second lifetime (dnsmasq also defaults its RA router lifetime to 1800s).
Notice two details that keep captures reliable on Linux: pass --immediate-mode to tcpdump so libpcap writes frames straight to slaac.pcap rather than buffering until exit, and wait for default via ... to appear in $H after bringing h-v6 up (because a veth link only gains carrier once both ends are up, so both sides finish link-local DAD and exchange RS/RA over roughly 2–5 seconds).
mkdir -p ~/ipv6-lab03 && cd ~/ipv6-lab03
unshare -n sleep infinity & H=$!
sleep 0.2
ip link add h-v6 address 02:00:00:00:60:10 type veth peer name r-v6 \
address 02:00:00:00:60:01
ip link set h-v6 netns $H
ip link set r-v6 up && ip addr add 2001:db8:10::1/64 dev r-v6
nsenter -t $H -n ip link set lo up
cat > d_slaac.conf <<'CONF'
interface=r-v6
bind-interfaces
enable-ra
dhcp-range=2001:db8:10::,ra-only,64,1800
dhcp-option=option6:dns-server,[2001:db8:10::53]
CONF
tcpdump --immediate-mode -Z "$(id -un)" -i r-v6 -nn -w slaac.pcap \
"icmp6" >/dev/null 2>&1 & TP=$!
sleep 0.4
dnsmasq --no-daemon --user="$(id -un)" --pid-file=dm.pid \
--dhcp-leasefile=dm.leases --conf-file=d_slaac.conf >/dev/null 2>&1 & DM=$!
sleep 0.4 && nsenter -t $H -n ip link set h-v6 up
for _ in $(seq 1 20); do
nsenter -t $H -n ip -6 route show | grep -q "^default " && break
sleep 0.5
done; sleep 1.2
nsenter -t $H -n ip -6 addr show dev h-v6
nsenter -t $H -n ip -6 route show
nsenter -t $H -n ping -6 -c 1 2001:db8:10::1
nsenter -t $H -n ip -6 neigh show dev h-v63: h-v6@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
inet6 2001:db8:10::ff:fe00:6010/64 scope global tentative dynamic mngtmpaddr
valid_lft 1799sec preferred_lft 1799sec
inet6 fe80::ff:fe00:6010/64 scope link
valid_lft forever preferred_lft forever
2001:db8:10::/64 dev h-v6 proto kernel metric 256 expires 1798sec pref medium
fe80::/64 dev h-v6 proto kernel metric 256 pref medium
default via fe80::ff:fe00:6001 dev h-v6 proto ra metric 1024 expires 1798sec
...
64 bytes from 2001:db8:10::1: icmp_seq=1 ttl=64 time=0.085 ms
2001:db8:10::1 lladdr 02:00:00:00:60:01 REACHABLE
fe80::ff:fe00:6001 lladdr 02:00:00:00:60:01 router DELAYLook at three details in that output. First, 2001:db8:10::ff:fe00:6010/64 is marked dynamic mngtmpaddr (tentative briefly while global DAD completes), showing that the kernel built a SLAAC /64 address directly from the RA prefix. Because this veth interface uses a fixed locally administered MAC (02:00:00:00:60:10), Linux derives its Modified EUI-64 suffix ff:fe00:6010 (when NetworkManager, systemd-networkd, or addr_gen_mode and use_tempaddr sysctls enable them, you will see RFC 7217 stable and RFC 8981 temporary addresses instead). Second, default via fe80::ff:fe00:6001 points to the router's link-local address (proto ra), never 2001:db8:10::1, per RFC 4861. Third, ip -6 neigh marks fe80::ff:fe00:6001 as router, letting Neighbor Unreachability Detection monitor gateway health.
03. Step 2: Read DAD, Router Solicitation and Router Advertisement frames
Predict before running: Look at slaac.pcap before decoding it. When h-v6 first came up without an IPv6 address, what source and destination addresses appeared in its link-local Duplicate Address Detection packet? And in ra-only mode, what will Flags [...] on the RA header and Flags [...] inside the Prefix Information Option print?
Stop the ra-only dnsmasq and tcpdump processes and decode slaac.pcap. If you open slaac.pcap in Wireshark on your desktop, apply the display filter icmpv6.type in {133, 134, 135, 136} to view RS, RA, NS, and NA frames cleanly.
kill $DM && wait $DM 2>/dev/null || true
sleep 0.3 && kill -INT $TP && wait $TP 2>/dev/null || true
tcpdump -r slaac.pcap -nn -vv11:11:54.731348 IP6 (hlim 255, next-header ICMPv6 (58) payload length: 32)
:: > ff02::1:ff00:6010: [icmp6 sum ok] ICMP6, neighbor solicitation, length 32,
who has fe80::ff:fe00:6010
11:11:55.756409 IP6 (hlim 255, next-header ICMPv6 (58) payload length: 16)
fe80::ff:fe00:6010 > ff02::2: [icmp6 sum ok] ICMP6, router solicitation, length 16
source link-address option (1), length 8 (1): 02:00:00:00:60:10
11:11:59.787555 IP6 (class 0xc0, flowlabel 0x4cadf, hlim 255, next-header ICMPv6 (58)
payload length: 88) fe80::ff:fe00:6001 > fe80::ff:fe00:6010: [icmp6 sum ok] ICMP6,
router advertisement, length 88
hop limit 64, Flags [none], pref medium, router lifetime 1800s
prefix info option (3), length 32 (4): 2001:db8:10::/64, Flags [onlink, auto],
valid time 1800s, pref. time 1800s
mtu option (5), length 8 (1): 1500
source link-address option (1), length 8 (1): 02:00:00:00:60:01
rdnss option (25), length 24 (3): lifetime 1800s, addr: 2001:db8:10::53
...Every line confirms the protocol flow: :: > ff02::1:ff00:6010 runs DAD from the unspecified source ::; fe80::ff:fe00:6010 > ff02::2 transmits the Router Solicitation; and the router responds with Flags [none] (M = 0, O = 0), router lifetime 1800s, prefix info ... Flags [onlink, auto] (A = 1), and rdnss DNS 2001:db8:10::53—all carrying hlim 255 as required by RFC 4861. (The full capture prints additional frames—router-side DAD for its own addresses, the router namespace's own RS because IPv6 forwarding is off, plus NS/NA and ping echo traffic.)
04. Step 3: Run stateless (O=1) and stateful (M=1, A=0) DHCPv6 clients and clean up
Now put SLAAC and DHCPv6 side by side with a real DHCPv6 client (dhclient -6). First, switch dnsmasq to ra-stateless (O = 1, A = 1) and run dhclient -6 -S (Information-Request -> Reply on UDP 546/547, multicast ff02::1:2). Second, reset h-v6 down/up before switching dnsmasq to a managed address range (2001:db8:10::100,2001:db8:10::200,64,600), which sets Flags [managed, other stateful] (M = 1, O = 1) and drops auto (A = 0) on the prefix so h-v6 skips SLAAC and requests a full 4-message DHCPv6 lease (Solicit -> Advertise -> Request -> Reply) via /sbin/dhclient-script.
Notice in m_flag.pcap that veth TX checksum offload prints [bad udp cksum ...] warnings in tcpdump (safe to ignore on veth pairs), and notice how h-v6 receives a /128 host address from DHCPv6 while its /64 on-link route and default via fe80::ff:fe00:6001 still come from the RA! (In Wireshark, filter these exchanges with dhcpv6 || icmpv6.type == 134.)
cat > d_stateless.conf <<'CONF'
interface=r-v6
bind-interfaces
enable-ra
dhcp-range=2001:db8:10::,ra-stateless,64,1800
dhcp-option=option6:dns-server,[2001:db8:10::53]
CONF
tcpdump --immediate-mode -Z "$(id -un)" -i r-v6 -nn -w o_flag.pcap \
"icmp6 or port 546 or port 547" >/dev/null 2>&1 & T2=$!
sleep 0.4; dnsmasq --no-daemon --user="$(id -un)" --pid-file=dm2.pid \
--dhcp-leasefile=dm2.leases --conf-file=d_stateless.conf >/dev/null 2>&1 & D2=$!
sleep 0.4
nsenter -t $H -n dhclient -6 -S -1 -v -lf /dev/null -pf /dev/null \
-sf /bin/true h-v6 2>&1 | grep -E "Info-Request|Reply" || true
sleep 1.5 && nsenter -t $H -n ip link set h-v6 down
kill $D2 2>/dev/null; wait $D2 2>/dev/null || true
sleep 0.2 && kill -INT $T2 && wait $T2 2>/dev/null || true
tcpdump -r o_flag.pcap -nn -vv | grep -E "router advertisement|Flags|prefix info|dhcp6"
cat > d_stateful.conf <<'CONF'
interface=r-v6
bind-interfaces
enable-ra
dhcp-range=2001:db8:10::100,2001:db8:10::200,64,600
dhcp-option=option6:dns-server,[2001:db8:10::53]
CONF
tcpdump --immediate-mode -Z "$(id -un)" -i r-v6 -nn -w m_flag.pcap \
"icmp6 or port 546 or port 547" >/dev/null 2>&1 & T3=$!
sleep 0.4; dnsmasq --no-daemon --user="$(id -un)" --pid-file=dm3.pid \
--dhcp-leasefile=dm3.leases --conf-file=d_stateful.conf >/dev/null 2>&1 & D3=$!
sleep 0.4 && nsenter -t $H -n ip link set h-v6 up
for _ in $(seq 1 20); do
nsenter -t $H -n ip -6 route show | grep -q "^default " && break
sleep 0.5
done
nsenter -t $H -n dhclient -6 -d -1 -v -lf /dev/null -pf /dev/null \
-sf /sbin/dhclient-script h-v6 >dhc.log 2>&1 & DH=$!
for _ in $(seq 1 20); do grep -q "RCV: Reply" dhc.log && break; sleep 0.5; done
grep -E "Solicit|Advertise|Request|Reply" dhc.log || true
sleep 1.5 && nsenter -t $H -n ip -6 addr show dev h-v6
nsenter -t $H -n ip -6 route show
nsenter -t $H -n ip link set h-v6 down
kill $DH 2>/dev/null; wait $DH 2>/dev/null || true
kill $D3 2>/dev/null; wait $D3 2>/dev/null || true
sleep 0.2 && kill -INT $T3 && wait $T3 2>/dev/null || true
tcpdump -r m_flag.pcap -nn -vv \
| grep -E "router advertisement|Flags|prefix info|dhcp6"
kill $H 2>/dev/null || true && ip link del r-v6 2>/dev/null || true
cd ~ && rm -rf ~/ipv6-lab03XMT: Forming Info-Request, 0 ms elapsed.
XMT: Info-Request on h-v6, interval 1050ms.
RCV: Reply message on h-v6 from fe80::ff:fe00:6001.
... fe80::ff:fe00:6010.546 > ff02::1:2.547: ... dhcp6 inf-req (...)
... fe80::ff:fe00:6001.547 > fe80::ff:fe00:6010.546: ... dhcp6 reply
(... DNS-server 2001:db8:10::53 ...)
hop limit 64, Flags [other stateful], pref medium, router lifetime 1800s
prefix info option (3), length 32 (4): 2001:db8:10::/64, Flags [onlink, auto],
...
XMT: Forming Solicit, 0 ms elapsed.
XMT: Solicit on h-v6, interval 1030ms.
RCV: Advertise message on h-v6 from fe80::ff:fe00:6001.
XMT: Forming Request, 0 ms elapsed.
XMT: Request on h-v6, interval 910ms.
RCV: Reply message on h-v6 from fe80::ff:fe00:6001.
3: h-v6@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
inet6 2001:db8:10::1b5/128 scope global tentative
inet6 fe80::ff:fe00:6010/64 scope link
2001:db8:10::1b5 dev h-v6 proto kernel metric 256 pref medium
2001:db8:10::/64 dev h-v6 proto kernel metric 256 expires 1796sec pref medium
fe80::/64 dev h-v6 proto kernel metric 256 pref medium
default via fe80::ff:fe00:6001 dev h-v6 proto ra metric 1024 expires 1796sec
hop limit 64, Flags [managed, other stateful], pref medium, router lifetime 1800s
prefix info option (3), length 32 (4): 2001:db8:10::/64, Flags [onlink],
... fe80::ff:fe00:6010.546 > ff02::1:2.547: ... dhcp6 solicit (...)
... fe80::ff:fe00:6001.547 > fe80::ff:fe00:6010.546: ... dhcp6 advertise
(... IA_ADDR 2001:db8:10::1b5 ...)
... fe80::ff:fe00:6010.546 > ff02::1:2.547: ... dhcp6 request (...)
... fe80::ff:fe00:6001.547 > fe80::ff:fe00:6010.546: ... dhcp6 reply
(... IA_ADDR 2001:db8:10::1b5 ...)05. Check your understanding
06. Apply it
Re-run Step 3 with dhcp-range=2001:db8:10::100,2001:db8:10::200,slaac,64,600 (adding the slaac keyword alongside the managed range) and inspect ip -6 addr on $H to see both the SLAAC /64 address and the stateful DHCPv6 /128 lease installed side by side on h-v6.
Next, move to the worked example on planning a /48 site to scale single-link RAs into a clean multi-VLAN addressing plan and dual-stack firewall policy.
07. Review prompt
Explain why h-v6 needs --immediate-mode on tcpdump and an isolated unshare namespace, why a stateful DHCPv6 lease shows /128 in ip -6 addr while relying on the RA for /64 on-link and default routing, and how dnsmasq RA flags change across ra-only, ra-stateless, and managed ranges.
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.