---
name: ipv6-ready-coding
description: >
  Use when writing or changing networking, sockets, DNS, bind/listen, HTTP clients,
  or IP address fields. Ensures code works on IPv6-only-strict and IPv6-only-with-NAT64
  paths and on dual-stack when both address families are present. Use for dual-stack,
  IPv6-only, AAAA, Happy Eyeballs, or getaddrinfo work even if the user does not say "IPv6".
---

# IPv6-ready coding

## Success bar

New or changed network code **MUST** work across the connectivity scenarios in
`ipv6-app-testing` (aligned with draft-ietf-v6ops-ipv6-app-testing and
draft-ietf-v6ops-ipv6-only terminology):

1. **IPv6-Only-Strict**: no usable IPv4 on the path (neither native nor via NAT64/encapsulation).
2. **IPv6-Only with NAT64** (when the deployment uses IPv4aaS): IPv6 native; IPv4 destinations only via translation/encapsulation.
3. **Dual-Stack**: when A and AAAA (or both families) are present, use family-agnostic APIs and Happy Eyeballs / full candidate lists so IPv6 is not skipped and IPv4 peers still work.

Say which **scope** you mean (host, lab VLAN, CI runner, production DC). “IPv6-only laptop” is not the same as “IPv6-Only-Strict” if NAT64 or a VPN restores IPv4.

Verification: exercise paths with AAAA present **and** with IPv4 absent (strict). "Works on my dual-stack laptop" is not IPv6-Only-Strict proof. Load `ipv6-app-testing` for the full matrix.

## Instructions

1. Prefer hostnames and service discovery over address literals in application logic.
2. Resolve with full-list APIs; connect with OS/library Happy Eyeballs when available. Load `ipv6-name-resolution` and `ipv6-destination-selection` for details.
3. Fix listen/bind for dual-stack and IPv6-only clients. Load `ipv6-localhost-bind` when touching loopback or `0.0.0.0` / `::`.
4. Check process and runtime config (JVM `preferIPv4Stack` / `preferIPv6Addresses`, Node DNS result order, probe `curl -4`). Load `ipv6-runtime-config`.
5. Store and compare addresses in 128-bit-capable forms. Load `ipv6-address-storage` for schemas and parsers.
6. In docs and examples prefer documentation prefixes `2001:db8::/32` and `3fff::/20` (canonical text).
7. Before claiming readiness, run `ipv6-code-review` on the diff or service and confirm tests cover the scenarios in `ipv6-app-testing`.

## Gotchas

- Dual-stack CI alone does not prove IPv6-Only-Strict; add a strict (or IPv4-absent) path.
- Do not invent IPv4-only helpers in new code "for simplicity."
- Client dials to `127.0.0.1` are often acceptable when loopback IPv4 remains; **listen** on `127.0.0.1` only is usually wrong for IPv6-local clients.
- Do not "harden" by blocking all ICMPv6; Path MTU Discovery and Neighbor Discovery need required ICMPv6 types. Load `ipv6-code-review` for the phrasing.
- Family-agnostic source with `java.net.preferIPv4Stack=true` (or similar) still fails IPv6 paths.

## Sibling skills

- `ipv6-app-testing`
- `ipv6-name-resolution`
- `ipv6-destination-selection`
- `ipv6-localhost-bind`
- `ipv6-runtime-config`
- `ipv6-address-storage`
- `ipv6-code-review`

## Source

- Hub: https://www.peachymango.org/ipv6
- https://datatracker.ietf.org/doc/draft-martin-deploying-ipv6-data-center/
- https://datatracker.ietf.org/doc/draft-ietf-v6ops-ipv6-app-testing/
- https://datatracker.ietf.org/doc/draft-ietf-v6ops-ipv6-only/
