A dual-stack server speaks both IPv4 and IPv6 on every service. The wire format is different, the listening sockets are different, the firewall rules are different — but to clients there is just one hostname that resolves to both A and AAAA, and the client picks. This article covers the end-to-end build: static addresses on both families, forward and reverse DNS, daemons configured to bind on both, the firewall split between iptables and ip6tables (or nftables), and the source-address selection rules that decide which IPv6 address a server uses outbound.
How to verify
Quick checks across the stack:
ip -4 addr show
ip -6 addr show scope global
ss -tlnp '( sport = :443 )'
dig +short A example.com
dig +short AAAA example.com
dig -x 2001:db8::1
curl -4 -fsS https://example.com >/dev/null && echo v4-ok
curl -6 -fsS https://example.com >/dev/null && echo v6-ok
ss -tlnp with the port filter shows whether the listening socket bound to both families. *:443 or [::]:443 indicates an IPv6 socket that the kernel maps onto IPv4 traffic when net.ipv6.bindv6only=0 (the default).
What’s happening
A dual-stack process can listen in one of three ways:
- Two separate sockets, one bound to
0.0.0.0:443for IPv4 and one to[::]:443for IPv6. This is the most explicit and what most production daemons do. - One IPv6 socket on
[::]:443with IPv4-mapped addresses enabled (net.ipv6.bindv6only=0). The kernel surfaces IPv4 connections as::ffff:1.2.3.4sources. Simpler but obscures which family delivered the request. - One socket bound to a specific IP per family, common when the box has multiple addresses and the service is exposed on only one.
For outgoing connections, source-address selection follows RFC 6724: prefer the family of the destination, prefer global over link-local, prefer matching scope, prefer longest matching prefix, then prefer outgoing source IP from ip -6 addr order (and from RFC 7217 stable privacy if enabled). The result is that a server with two IPv6 addresses — say one SLAAC and one statically configured — may surprise you about which appears as the source on outbound traffic.
Happy Eyeballs (RFC 8305) is the client-side companion: dual-stack clients try v6 and v4 in parallel with a small head start for v6, picking whichever connects first. As a server operator you do not implement it, but it explains why a partial IPv6 outage on your end produces silent fallback to v4 from clients.
The procedure
-
Set static addresses on both families. systemd-networkd is the simplest path:
# /etc/systemd/network/10-eth0.network [Match] Name=eth0 [Network] Address=203.0.113.42/24 Address=2001:db8:1::42/64 Gateway=203.0.113.1 Gateway=2001:db8:1::1 DNS=1.1.1.1 DNS=2606:4700:4700::1111 -
Publish A, AAAA, and PTR records.
# In the forward zone web1 IN A 203.0.113.42 web1 IN AAAA 2001:db8:1::42 # Reverse: in the v4 reverse zone 42.113.0.203.in-addr.arpa. IN PTR web1.example.com. # Reverse: in the v6 reverse zone (one nibble per label) 2.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa. IN PTR web1.example.com.For the v6 PTR, the
arpa-nametool frombind9utilsgenerates the label automatically:arpaname 2001:db8:1::42 -
Bind your daemon on both families. Nginx default:
listen 443 ssl http2; listen [::]:443 ssl http2;Apache:
Listen 0.0.0.0:443 Listen [::]:443Postfix:
inet_protocols = all # listen on both inet_interfaces = all # all addresses on both families -
Allow both firewalls. iptables and ip6tables are independent — a rule in one does nothing in the other.
iptables -A INPUT -p tcp --dport 443 -j ACCEPT ip6tables -A INPUT -p tcp --dport 443 -j ACCEPT # ICMPv6 NDP is mandatory — never blanket-block ICMPv6 ip6tables -A INPUT -p ipv6-icmp -j ACCEPTOr with nftables (the modern path), use a single
inettable to cover both:table inet filter { chain input { type filter hook input priority 0; ct state established,related accept iif lo accept ip6 nexthdr ipv6-icmp accept tcp dport 443 accept counter drop } } -
Pin outbound source for IPv6 if needed. Some daemons (postfix smtp client, custom services) honour an explicit source-address config. For postfix:
smtp_bind_address = 203.0.113.42 smtp_bind_address6 = 2001:db8:1::42 -
Verify reverse DNS for mail. Both the v4 and v6 PTR records must match the forward hostname for mail receivers to accept the connection. Mail providers reject IPv6 SMTP clients without a valid AAAA→PTR→forward match more aggressively than IPv4.
Operational notes
- Disable
accept_raon servers with static IPv6. Otherwise the host adds a SLAAC address alongside the static one, and source-address selection may pick the wrong one.sysctl -w net.ipv6.conf.eth0.accept_ra=0. net.ipv6.bindv6onlydefaults to 0 on Linux — the same socket bound on[::]:443accepts IPv4 too via 4-mapped addresses. Set to 1 if you want strict separation.- Happy Eyeballs hides your bugs. A broken IPv6 path stays invisible until enough clients fail v4 simultaneously; dual-stack failure mode is silent partial degradation. Add explicit AAAA-only health checks.
- NAT64/DNS64 environments (mobile carriers) synthesise AAAA records from your A. If your server speaks only IPv4 but a client is v6-only behind NAT64, the connection works through the carrier’s NAT — but logs show synthetic source addresses.
- Reverse zones for IPv6 are managed differently per registrar. Some ISPs delegate /48 reverse zones to your DNS; others want individual PTR updates via a portal. Confirm the model before publishing AAAA records widely.
In the engagements we run, dual-stack is the baseline on every new estate. The build above — static both families, full DNS coverage, two-family firewall, nftables for new boxes — is what the managed-operations practice ships as the default Ansible role for any internet-facing host. We surface “AAAA missing for hostname X” as a finding in our standard onboarding audit because v6 coverage is still the single most common gap we see in inherited estates.