Lesson 8 of 9 · 24m
Making Applications IPv6-Ready
Sockets, bind addresses, literals, DNS resolution, dependency behavior, logging, and the code-level assumptions that break IPv6 in otherwise healthy networks.
Networks get blamed for application bugs because applications are where users see the failure. In reality, a huge amount of IPv6 readiness is mundane software hygiene: bind correctly, resolve correctly, store addresses correctly, and stop parsing IP strings as if the world ended in 1995.
Listen on the right socket, not the familiar one
An application that binds 0.0.0.0 listens on IPv4 only. Binding :: may listen on IPv6 only or both families depending on the operating system and socket options. Do not guess; verify.
ss -lntup | grep ':443'In Go, a listener on tcp normally handles both families when the operating system permits it. In Python, address family behavior is explicit if you create sockets manually. In nginx, be deliberate:
server { listen 443 ssl; listen [::]:443 ssl; server_name www.example.net; }If the second line is missing on a dual-stack host, the network team can publish AAAA records all day; the service still will not answer over IPv6.
Use resolution APIs instead of address-family assumptions
Old code often calls IPv4-only APIs or assumes dotted-quad output. Modern code should use getaddrinfo or its platform equivalent and iterate over results:
import socket
infos = socket.getaddrinfo("www.example.net", 443, type=socket.SOCK_STREAM)
for family, socktype, proto, _, sockaddr in infos:
print(family, sockaddr)This is how Happy Eyeballs-capable clients get address candidates. Hard-coding AF_INET or validating input with an IPv4-only regular expression silently excludes IPv6.
Literals and URLs need correct syntax
IPv6 literals in URLs use brackets:
https://[2001:db8:3f10:220::20]/healthZone identifiers for link-local addresses add another layer: fe80::1%eth0 locally, often percent-encoded in URI contexts. Configuration parsers must not split on : blindly. A host-port parser written for IPv4 will shred an IPv6 literal unless brackets are handled deliberately.
Store addresses as data, not as vibes
Use native IP address types where available. PostgreSQL has inet; many languages have robust IP address classes. String storage is sometimes unavoidable, but validation and canonicalization should still use a real parser. Logs should preserve the actual peer address family. If your load balancer terminates connections, pass original client information explicitly and document whether IPv6 addresses can appear there.
Test application behavior through both families
Unit tests can verify parsers, but production readiness needs integration checks:
curl -4 -I https://www.example.net/health && curl -6 -I https://www.example.net/healthThen test real workflows: login, cookies, redirects, API callbacks, uploads, WebSockets, mail delivery, and third-party webhooks. Redirects that embed an IPv4-only literal or hostname without AAAA can break after the first successful response.
Field notes
- IPv6 readiness includes dependencies: proxies, SDKs, metrics agents, service meshes, and secrets managers.
- Reverse proxies can hide client addresses; preserve
X-Forwarded-Foror PROXY protocol carefully and validate trust boundaries. - Do not rate-limit by individual /128 alone — privacy addressing rotates. Report IPv4-only SDK parsing as a bug instead of compensating locally.
Was this lesson helpful?