Your first dual-stack network
Build a routed two-subnet network that carries IPv4 and IPv6 side by side, without needing IPv6 from an ISP. Explain how a dual-stack host orders destination addresses (RFC 6724) and races connections (Happy Eyeballs, RFC 8305). Verify end-to-end reachability over each protocol separately, and diagnose the most common dual-stack mistakes.
Take the quiz · pass mark 70% · 8 questions
Explanation
What "dual stack" means
A dual-stack network runs IPv4 and IPv6 at the same time on the same links. Every host and router interface has addresses of both families, routers forward both, and DNS publishes both A (IPv4) and AAAA (IPv6) records. The two protocols do not interact. They are two independent networks sharing cables, switches and router boxes.
Dual stack is the most common way to introduce IPv6. It is low-risk because IPv4 keeps working. The catch is that you now operate two networks, and a fault in one can be hidden by the other.
The lab network
Drawing diagram…
| Item | IPv6 | IPv4 |
|---|---|---|
| LAN A | 2001:db8:50:1::/64 (SLAAC from router RAs) | 192.0.2.0/25 |
| LAN B | 2001:db8:50:2::/64 | 192.0.2.128/25 |
| Router | ::1 on each LAN | .1 and .129 |
| Server | 2001:db8:50:2::80 (static) | 192.0.2.180 |
| Name | www.lab.example, with both AAAA and A |
All addresses come from documentation ranges (RFC 3849, RFC 5737), so the lab never collides with a real network, and it needs no IPv6 from your ISP.
What the router has to do for each protocol
| Task | IPv4 | IPv6 |
|---|---|---|
| Interface addresses | Static /25s | Static /64s (link-local addresses appear automatically) |
| Forwarding | net.ipv4.ip_forward=1 | net.ipv6.conf.all.forwarding=1 |
| Host addressing | Static (or DHCPv4) | Router Advertisements with a PIO (A=1) so hosts use SLAAC (RFC 4861, RFC 4862) |
| Default gateway for hosts | Configured or via DHCPv4 | Learned from the RA: the router's link-local address |
| DNS for hosts | DHCPv4 option or static | RDNSS option in the RA (RFC 8106) or DHCPv6 |
Note: on Linux, enabling IPv6 forwarding makes the router ignore RAs on its own interfaces (unless accept_ra=2). That is what you want for a router.
How a dual-stack host picks a destination address
When an application calls getaddrinfo("www.lab.example"), it gets back both addresses. The OS sorts them using RFC 6724 destination address selection. Among its rules, the decisive one in a normal dual-stack network is precedence from the default policy table:
| Prefix | Precedence | Label | Meaning |
|---|---|---|---|
::1/128 | 50 | 0 | Loopback |
::/0 | 40 | 1 | IPv6 in general (GUA) |
::ffff:0:0/96 | 35 | 4 | IPv4 (as IPv4-mapped) |
2002::/16 | 30 | 2 | 6to4 |
2001::/32 | 5 | 5 | Teredo |
fc00::/7 | 3 | 13 | ULA |
::/96 | 1 | 3 | IPv4-compatible (deprecated) |
fec0::/10 | 1 | 11 | Site-local (deprecated) |
3ffe::/16 | 1 | 12 | 6bone (returned) |
So with a working global IPv6 address, IPv6 (40) is preferred over IPv4 (35). Two consequences:
- A ULA destination (precedence 3) loses to IPv4 (35) unless policy is changed. (Hosts may add site-specific rows, but you should know the default.)
- RFC 6724 also prefers destinations whose scope and label match an available source address. A host with only a link-local IPv6 address will not prefer IPv6 for global destinations, because it has no usable global IPv6 source.
On Linux the policy table is /etc/gai.conf. On Windows, netsh interface ipv6 show prefixpolicies shows it.
Happy Eyeballs: racing the two protocols
Strict "IPv6 first, then IPv4" ordering would make users wait for a full TCP timeout whenever the IPv6 path is broken. Happy Eyeballs v2 (RFC 8305) avoids this:
Drawing diagram…
Recommended defaults from RFC 8305:
- Resolution Delay: 50 ms. If the A answer arrives first, wait up to 50 ms for the AAAA answer before connecting over IPv4.
- Connection Attempt Delay: 250 ms. Start the next address family's attempt if the first has not connected by then.
- Implementations vary. For example, curl has its own default (set with
--happy-eyeballs-timeout-ms), and browsers tune their own values.
Happy Eyeballs is great for users and dangerous for operators: a broken IPv6 path may cost users only 250 ms, so nobody reports it. Always test each protocol separately (-4 / -6).
The dual-stack verification checklist
- Addresses: every interface has a global IPv6 address and an IPv4 address (
ip addr). - Default routes: the host has an IPv6 default route via the router's link-local address, and an IPv4 default route.
- Per-protocol reachability:
ping -6andping -4to the far side;traceroute -6andtraceroute -4show the router as the first hop. - DNS: the name resolves to both AAAA and A (
getent ahosts,dig AAAA/dig A). - Application:
curl -6andcurl -4both work; then plaincurlshows which family is chosen. - Failure test: break IPv6 and confirm the fallback works and how long it takes.
The usual mistakes
| Symptom | Likely cause |
|---|---|
Hosts have only fe80:: addresses | No RA, an RA without a PIO, A=0, or a prefix that is not a /64 |
| Hosts have a GUA but no IPv6 default route | RA router lifetime is 0, or RAs are blocked |
| IPv6 works on the LAN but not across the router | IPv6 forwarding is not enabled (IPv4 forwarding often is) |
| Ping works, but large transfers hang | ICMPv6 Packet Too Big is filtered somewhere |
| "IPv6 works" but traffic graphs show only IPv4 | Missing AAAA records, or a host preferring IPv4 (policy, ULA-only, no global address) |
Worked examples
Example 1: Which destination is tried first?
Question: The client has a global IPv6 address and an IPv4 address. www.lab.example resolves to 2001:db8:50:2::80 and 192.0.2.180. With the default policy table, which is tried first?
Working: 2001:db8:50:2::80 matches ::/0 (precedence 40). 192.0.2.180 is treated as ::ffff:192.0.2.180 (precedence 35). IPv6 is tried first.
Example 2: The ULA trap
Question: A different host has only a ULA IPv6 address and a public IPv4 address. A service has a ULA AAAA record and an A record. Which does a default RFC 6724 host prefer?
Working: ULA precedence is 3 and IPv4 is 35, so IPv4 is preferred, unless the site adds a policy-table row. This is a common surprise in ULA-only designs.
Example 3: Happy Eyeballs timing
Question: The A answer arrives at 20 ms and the AAAA answer at 40 ms. The IPv6 path silently drops packets. With RFC 8305 defaults, when is the IPv4 connection attempt started?
Working: The AAAA answer arrives within the 50 ms Resolution Delay (20 + 50 = 70 ms), so IPv6 is tried first, at 40 ms. The Connection Attempt Delay is 250 ms, so IPv4 starts at 40 + 250 = 290 ms.
Example 4: Summarising the lab prefixes
Question: What is the shortest single prefix that covers both 2001:db8:50:1::/64 and 2001:db8:50:2::/64?
Working: The fourth groups are 0001 and 0010. They agree on their first 14 bits and differ in bits 15 and 16 of that group, so the common prefix is 48 + 14 = 62 bits: 2001:db8:50::/62. It also covers 2001:db8:50::/64 and 2001:db8:50:3::/64.
Lab
Goal: Build the dual-stack network above, verify each protocol separately, and watch address selection and Happy Eyeballs at work.
You need: Linux with iproute2, radvd, curl, Python 3 and tcpdump. Optional: containerlab with FRR, or MikroTik RouterOS CHR, for the router. The equivalent configuration is given at the end. Nothing here touches your real network.
Step 1: Build the topology
for n in client router server; do sudo ip netns add $n; sudo ip -n $n link set lo up; done
sudo ip link add c0 netns client type veth peer name eth-a netns router
sudo ip link add s0 netns server type veth peer name eth-b netns router
sudo ip -n client link set c0 up; sudo ip -n server link set s0 up
sudo ip -n router link set eth-a up; sudo ip -n router link set eth-b up
# Router: addresses and forwarding for both families
sudo ip -n router addr add 192.0.2.1/25 dev eth-a
sudo ip -n router addr add 192.0.2.129/25 dev eth-b
sudo ip -n router -6 addr add 2001:db8:50:1::1/64 dev eth-a
sudo ip -n router -6 addr add 2001:db8:50:2::1/64 dev eth-b
sudo ip netns exec router sysctl -qw net.ipv4.ip_forward=1
sudo ip netns exec router sysctl -qw net.ipv6.conf.all.forwarding=1
# Server: static addressing for both families
sudo ip -n server addr add 192.0.2.180/25 dev s0
sudo ip -n server route add default via 192.0.2.129
sudo ip -n server -6 addr add 2001:db8:50:2::80/64 dev s0
# (the server's IPv6 default route will come from the RA on LAN B)
# Client: static IPv4; IPv6 comes from SLAAC
sudo ip -n client addr add 192.0.2.10/25 dev c0
sudo ip -n client route add default via 192.0.2.1
Step 2: Router Advertisements on both LANs
cat <<'EOF2' | sudo tee /tmp/radvd-l107.conf
interface eth-a { AdvSendAdvert on; MaxRtrAdvInterval 15;
prefix 2001:db8:50:1::/64 { AdvOnLink on; AdvAutonomous on; };
RDNSS 2001:db8:50:2::53 { }; };
interface eth-b { AdvSendAdvert on; MaxRtrAdvInterval 15;
prefix 2001:db8:50:2::/64 { AdvOnLink on; AdvAutonomous on; }; };
EOF2
sudo ip netns exec router radvd -C /tmp/radvd-l107.conf -p /tmp/radvd-l107.pid
sleep 10
sudo ip -n client -6 addr show dev c0
sudo ip -n client -6 route show default
The client should now have a SLAAC address in 2001:db8:50:1::/64 and an IPv6 default route via the router's fe80:: address.
Step 3: A dual-stack service and a name
sudo ip netns exec server python3 -m http.server 8080 --bind :: >/dev/null 2>&1 &
sudo mkdir -p /etc/netns/client
printf '2001:db8:50:2::80 www.lab.example\n192.0.2.180 www.lab.example\n' | sudo tee /etc/netns/client/hosts
(ip netns exec bind-mounts files from /etc/netns/client/ over /etc inside the namespace, so this hosts file is seen only by the client.)
Step 4: Verify each protocol separately
sudo ip netns exec client ping -6 -c 2 2001:db8:50:2::80
sudo ip netns exec client ping -4 -c 2 192.0.2.180
sudo ip netns exec client traceroute -6 -n 2001:db8:50:2::80 # or tracepath -6
sudo ip netns exec client getent ahosts www.lab.example
sudo ip netns exec client curl -6 -s -o /dev/null -w 'v6 %{remote_ip}\n' http://www.lab.example:8080/
sudo ip netns exec client curl -4 -s -o /dev/null -w 'v4 %{remote_ip}\n' http://www.lab.example:8080/
sudo ip netns exec client curl -s -o /dev/null -w 'default %{remote_ip}\n' http://www.lab.example:8080/
Record which address getent ahosts lists first and which one plain curl uses. Explain both using the RFC 6724 precedence table.
Step 5: Change address selection
printf 'precedence ::1/128 50\nprecedence ::/0 40\nprecedence ::ffff:0:0/96 100\n' | sudo tee /etc/netns/client/gai.conf
sudo ip netns exec client getent ahosts www.lab.example
sudo rm /etc/netns/client/gai.conf
Explain why IPv4 is now listed first.
Step 6: Break IPv6 and time the fallback
sudo ip -n router -6 route add blackhole 2001:db8:50:2::80/128
sudo ip netns exec client curl -s -o /dev/null -w 'connect %{time_connect}s via %{remote_ip}\n' http://www.lab.example:8080/
sudo ip netns exec client curl -s -o /dev/null --happy-eyeballs-timeout-ms 1000 -w 'connect %{time_connect}s via %{remote_ip}\n' http://www.lab.example:8080/
sudo ip netns exec client curl -6 -s -m 5 -o /dev/null -w '%{http_code}\n' http://www.lab.example:8080/ || echo "IPv6 FAILED"
sudo ip -n router -6 route del blackhole 2001:db8:50:2::80/128
Record the connect times. Explain why the user barely notices the outage, and why curl -6 (testing one protocol only) is the check that reveals it.
Optional: the same router on FRR or RouterOS
FRR (vtysh):
interface eth-a
ip address 192.0.2.1/25
ipv6 address 2001:db8:50:1::1/64
ipv6 nd prefix 2001:db8:50:1::/64
no ipv6 nd suppress-ra
RouterOS v7:
/ip address add address=192.0.2.1/25 interface=ether2
/ipv6 address add address=2001:db8:50:1::1/64 interface=ether2 advertise=yes
/ipv6 nd set [find interface=ether2] advertise-dns=yes
Clean up
sudo pkill radvd; sudo pkill -f "http.server 8080"
for n in client router server; do sudo ip netns del $n; done
sudo rm -rf /etc/netns/client
Summary
- Dual stack runs IPv4 and IPv6 independently on the same links. Routers need forwarding and addressing for both, and IPv6 hosts get their addresses and default gateway from RAs.
getaddrinfosorts addresses by RFC 6724. With the default policy table, global IPv6 (precedence 40) beats IPv4 (35), and IPv4 beats ULA (3). Linux uses/etc/gai.conf.- Happy Eyeballs (RFC 8305) races the families: a 50 ms Resolution Delay and a 250 ms Connection Attempt Delay by default. Users hardly notice a broken IPv6 path, so always test
-4and-6separately. - Use the verification checklist (addresses, default routes, per-protocol ping and traceroute, DNS, application, failure test) and know the classic mistakes.
- This completes Level 1. Next: the Level 1 exam, then Level 2 (Addressing and Address Planning).
Quiz imported · 8 questions · pass mark 70%. Lab questions are not auto-marked.