IPv6
IPv6 replaces the 32-bit IPv4 address space, which ran out of new allocations at the regional registries between 2011 and 2015, with 128-bit addresses. The larger space is the main reason it exists. The protocol also removed IPv4 features that slowed routers down and replaced broadcast-based discovery with multicast.
Address format
Section titled “Address format”
An IPv6 address is 128 bits, written as eight groups of four hex digits.
Full: 2001:0db8:0000:0000:0000:ff00:0042:8329Short: 2001:db8::ff00:42:8329Two rules shorten it:
- Drop leading zeros in each group:
0db8becomesdb8,0042becomes42. - Replace one run of all-zero groups with
::. Use it once only, or the address is ambiguous.
Address types
Section titled “Address types”IPv6 has no broadcast. Its place is taken by multicast groups, and a new type, anycast, delivers to the nearest member of a group.
| Type | Delivered to | Example |
|---|---|---|
| Unicast | One interface | 2001:db8:abcd:1::10 |
| Multicast | Every member of a group | ff02::1 (all nodes on the link), ff02::2 (all routers) |
| Anycast | The nearest interface sharing the address | Same address on several servers, routing picks the closest |
Reserved ranges
Section titled “Reserved ranges”| Prefix | Purpose |
|---|---|
::1/128 | Loopback (equivalent to 127.0.0.1) |
fe80::/10 | Link-local. Auto-configured on every interface, never routed |
fc00::/7 | Unique local addresses (fd00::/8 in practice). The counterpart of RFC 1918 private space |
ff00::/8 | Multicast |
2000::/3 | Global unicast, the routable public range |
2001:db8::/32 | Documentation, never routed |
::ffff:0:0/96 | IPv4-mapped addresses, used by dual-stack sockets |
Prefix lengths
Section titled “Prefix lengths”The first 64 bits identify the network and the last 64 bits identify the interface. A typical allocation is a /48 or /56 per site, split into /64 subnets. Always use a /64 for a subnet. SLAAC (below) depends on it, and there is no address shortage to justify anything smaller.
2001:db8:abcd:0001:5054:00ff:fe12:3456|---- /48 site ----|subnet|---- interface ID ----|The header
Section titled “The header”
The base header is a fixed 40 bytes. IPv4’s is 20 bytes or more, with options.
| Field | Size | Purpose |
|---|---|---|
| Version | 4 bits | 6 |
| Traffic Class | 8 bits | Same role as IPv4 DSCP and ECN |
| Flow Label | 20 bits | Marks packets of one flow so routers can treat them together without reading the transport header |
| Payload Length | 16 bits | Bytes after the base header |
| Next Header | 8 bits | Upper-layer protocol (6 TCP, 17 UDP, 58 ICMPv6), or the next extension header |
| Hop Limit | 8 bits | The TTL equivalent. Decremented per hop, dropped at 0 |
| Source and Destination | 128 bits each | Addresses |
Three IPv4 features were removed on purpose:
| Removed | Why | What replaces it |
|---|---|---|
| Header checksum | Link layer and transport layer already check, and the router would otherwise recompute it at every hop | Nothing. UDP over IPv6 must therefore use its own checksum |
| Fragmentation by routers | Splitting packets slows the forwarding path | The source fragments, using a Fragment extension header. A router that cannot forward a packet drops it and sends ICMPv6 “Packet Too Big” |
| Options in the base header | Variable length complicates hardware | Extension headers chained through Next Header |
Every IPv6 link must support an MTU of at least 1280 bytes. Hosts discover the path MTU from Packet Too Big messages, so unlike IPv4 there is no option to fall back on fragmenting in the middle of the path.
Address configuration
Section titled “Address configuration”An IPv6 interface normally holds several addresses at once: a link-local address, one or more global addresses, and often a temporary one. Three mechanisms provide them.
Stateless address autoconfiguration lets a host build its own global address without a server that tracks leases.
- The host creates a link-local address (
fe80::plus an interface ID). - It sends a Router Solicitation to
ff02::2. - A router replies with a Router Advertisement (RA) carrying the
/64prefix, the default router lifetime, and flags that say what else to ask for. - The host combines the prefix with an interface ID and checks that nobody else uses the address (see Neighbor Discovery below).
- The default route is learned from the RA’s source, which is why
ip -6 routeshows a link-local next hop.
Routers also send unsolicited RAs periodically. A host’s DNS server can come from the RA itself (the RDNSS option) or from DHCPv6.
The interface ID used to be derived from the MAC address (EUI-64), which exposed the hardware address and let a device be tracked across networks. Modern systems use a stable random ID per network (RFC 7217) and rotate temporary addresses (RFC 4941) for outbound connections. That is why one interface shows several global addresses.
DHCPv6
Section titled “DHCPv6”DHCPv6 works in two modes, selected by flags in the RA:
| Mode | RA flag | What DHCPv6 provides |
|---|---|---|
| Stateless | O (other config) | DNS servers and similar options. The address still comes from SLAAC |
| Stateful | M (managed) | The address itself, with leases and reservations, like DHCPv4 |
DHCPv6 does not carry a default gateway. The router address always comes from the RA. Android does not support stateful DHCPv6, so a network with Android clients needs SLAAC.
Neighbor Discovery
Section titled “Neighbor Discovery”Neighbor Discovery Protocol (NDP) runs over ICMPv6 and replaces ARP. It uses multicast, not broadcast, so uninterested hosts are not interrupted.
| ICMPv6 type | Message | Used for |
|---|---|---|
| 133 | Router Solicitation | ”Is there a router here?“ |
| 134 | Router Advertisement | Prefix, default router, flags |
| 135 | Neighbor Solicitation | ”Who has this address?” Also duplicate address detection |
| 136 | Neighbor Advertisement | The answer, with the MAC address |
A Neighbor Solicitation for address X goes to the solicited-node multicast address ff02::1:ff plus the last 24 bits of X, so only hosts with a matching suffix listen. Before using a new address, the host sends a solicitation for it from the unspecified address ::. If no one answers, the address is unique. This is duplicate address detection.
Because NDP is the equivalent of ARP, it has the equivalent weakness: any host on the link can claim to be the router or a neighbor. Switch features such as RA Guard address this. See Network hardening.
# Addresses on an interfaceip -6 addr show dev eth0# inet6 2001:db8:abcd:1:5054:ff:fe12:3456/64 scope global dynamic mngtmpaddr# inet6 fe80::5054:ff:fe12:3456/64 scope link
# Default route learned from a Router Advertisementip -6 route show default# default via fe80::1 dev eth0 proto ra metric 1024 expires 1790sec
# Neighbor cache (the IPv6 ARP table)ip -6 neigh show# fe80::1 dev eth0 lladdr 00:00:5e:00:02:01 router REACHABLE
# Watch NDP and other ICMPv6 on the wiresudo tcpdump -i eth0 -n icmp6
# Link-local addresses need the interface nameping -6 fe80::1%eth0ICMPv6 is not optional
Section titled “ICMPv6 is not optional”In IPv4, many networks block ICMP wholesale and survive. In IPv6 that breaks the protocol, because address resolution, router discovery, and path MTU discovery all use ICMPv6.
sudo nft add rule inet filter input icmpv6 type \ { destination-unreachable, packet-too-big, time-exceeded, parameter-problem, \ nd-router-solicit, nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert } acceptRunning IPv4 and IPv6 together
Section titled “Running IPv4 and IPv6 together”
A single cutover is impossible, so the two protocols coexist. Three approaches exist, and most networks use the first.
| Method | How it works | When to use |
|---|---|---|
| Dual-stack | Every device runs IPv4 and IPv6 at once | Default choice. Native IPv6 where available |
| Tunneling | An IPv6 packet is carried inside an IPv4 packet (IP protocol 41) | Two IPv6 sites connected over an IPv4-only path |
| Translation (NAT64) | A gateway converts between IPv6 and IPv4 | IPv6-only clients that must reach IPv4-only services |
Tunneling
Section titled “Tunneling”The tunnel entrance wraps the whole IPv6 datagram as the payload of an IPv4 datagram. The outer source and destination are the two tunnel endpoints. Routers in between forward it as ordinary IPv4. At the exit, the endpoint sees protocol 41, strips the outer header, and forwards the IPv6 packet on.
IPv6 host A -> [ tunnel entrance ] ==== IPv4 network ==== [ tunnel exit ] -> IPv6 host B outer: IPv4 src = entrance, dst = exit, protocol = 41 inner: the original IPv6 datagramThe extra 20-byte header reduces the MTU, with the same black-hole risk described earlier. Static 6in4 tunnels are predictable but do not work through NAT. Tunnel brokers use protocols such as AYIYA when NAT is in the way. Automatic mechanisms such as 6to4 and Teredo are deprecated.
NAT64 and DNS64
Section titled “NAT64 and DNS64”In an IPv6-only network, a DNS64 resolver invents AAAA records for IPv4-only names by embedding the IPv4 address in a 64:ff9b::/96 prefix. The client sends IPv6 to that address, and the NAT64 gateway translates the packet to IPv4. Mobile carriers use this widely, so IPv6-only clients can still reach the whole internet.
Client behavior: Happy Eyeballs
Section titled “Client behavior: Happy Eyeballs”A dual-stack client that resolves both A and AAAA records does not wait for IPv6 to fail. It starts an IPv6 connection, starts IPv4 a few hundred milliseconds later if IPv6 has not completed, and uses whichever connects first (RFC 8305). A broken IPv6 path therefore shows up as small delays and not as an outage, which makes it easy to miss.
Cloud and Kubernetes notes
Section titled “Cloud and Kubernetes notes”- AWS allocates a
/56IPv6 block per VPC and a/64per subnet. IPv6 addresses are globally routable, so there is no NAT. An egress-only internet gateway gives private subnets outbound-only access, which is the IPv6 equivalent of a NAT gateway for policy purposes. - Security groups and network ACLs have separate IPv6 rules. A rule for
0.0.0.0/0does not cover::/0. - Kubernetes supports dual-stack pods and Services (stable since 1.23). Each pod gets its own IPv6 address, so pods and Services can be reached without NAT. See Kubernetes Services.
Commands
Section titled “Commands”# Does the name have an IPv6 address?dig AAAA app.example.com +short
# Force one familycurl -4 -sI https://app.example.com/ | head -1curl -6 -sI https://app.example.com/ | head -1
# Path and reachability over IPv6ping -6 -c 3 app.example.comtraceroute -6 app.example.commtr -6 -rwc 10 app.example.com
# Routes and socketsip -6 route showss -6 -tlnpTroubleshooting
Section titled “Troubleshooting”| Symptom | Likely cause | Fix |
|---|---|---|
Site is slow, but fast with curl -4 | The IPv6 path is broken and clients wait before falling back | Test with curl -6, then fix the route, firewall, or remove the AAAA record |
Host has fe80:: only, no global address | No Router Advertisement received | Check the router’s RA config and that RAs are not filtered. Check net.ipv6.conf.eth0.accept_ra |
| Local IPv6 works, off-link fails | No default route, or the upstream does not route the prefix | Check ip -6 route show default and the upstream allocation |
| Large transfers stall, small ones work | ICMPv6 Packet Too Big is blocked | Allow ICMPv6 types 1 to 4 |
ping fe80::1 says invalid argument | Link-local needs a scope | Use ping fe80::1%eth0 |
| Service reachable on IPv4 only | Daemon listens on 0.0.0.0, not :: | Bind to :: (a dual-stack socket also accepts IPv4) |
| Cloud instance has no IPv6 inbound | Security group has no ::/0 rule | Add the IPv6 rule |