IPv6
IPv4 uses 32-bit addresses - about 4.3 billion of them. That sounded infinite in the 1980s, but the internet ran out. NAT and CIDR bought time, but the real fix is a bigger address space: IPv6, with 128-bit addresses.
Why IPv6
128 bits is roughly 3.4 x 10^38 addresses - enough to give every grain of sand on Earth its own range many times over. Address exhaustion simply stops being a concern, which lets every device have a globally unique, routable address and removes the main reason NAT exists.
Address notation
An IPv6 address is written as 8 groups of 4 hex digits, separated by colons:
2001:0db8:0000:0000:0000:ff00:0042:8329
Two shorthand rules make this manageable:
- Drop leading zeros in each group:
2001:db8:0:0:0:ff00:42:8329. ::compression collapses one run of consecutive all-zero groups:2001:db8::ff00:42:8329.
:: rule - only once:: may appear at most once in an address. If it appeared twice, you could not
tell how many zero groups each :: stood for, so the address would be ambiguous.
A parser expands the single :: to however many zero groups are needed to reach 8
groups total.
Worked example: carving subnets out of a /48
An ISP typically hands a customer site a /48 allocation, for example
2001:db8:1234::/48. The customer owns every address from
2001:db8:1234:0000:: through 2001:db8:1234:ffff:ffff:ffff:ffff:ffff, that is
48 fixed bits followed by 80 bits the customer controls.
The customer subnets by carving out /64s (the standard size for a single LAN
segment), which leaves 64 - 48 = 16 bits free for subnet numbers - room for
2^16 = 65,536 separate /64 subnets from one /48:
| Subnet # | Prefix | Use |
|---|---|---|
| 0 | 2001:db8:1234:0000::/64 | Office LAN |
| 1 | 2001:db8:1234:0001::/64 | Guest Wi-Fi |
| 163 | 2001:db8:1234:00a3::/64 | Data center rack 3 |
Each of those /64s still leaves 128 - 64 = 64 bits for host addresses inside it
- vastly more than any single LAN will ever need, which is exactly why IPv6
subnetting math stops being a scarce-resource puzzle the way IPv4
/24-splitting is.
IPv4 vs IPv6
| IPv4 | IPv6 | |
|---|---|---|
| Address size | 32 bits | 128 bits |
| Notation | Dotted decimal (192.168.1.1) | Hex groups with :: (2001:db8::1) |
| Total addresses | ~4.3 billion | ~3.4 x 10^38 |
| Header | Variable length, more fields | Fixed 40-byte header, simplified |
| NAT | Common (address scarcity) | Not needed (abundant addresses) |
Simplified header
IPv6 streamlines the header on purpose. It has a fixed 40-byte size, drops rarely-used IPv4 fields, and removes the header checksum (Layer 2 and Layer 4 already check integrity). Optional features move into chained extension headers, so routers parse the common case faster.
Transition mechanisms
The internet cannot switch overnight, so IPv4 and IPv6 coexist:
- Dual-stack - a host or router runs both IPv4 and IPv6 and uses whichever the other end supports. This is the most common approach.
- Tunneling - IPv6 packets are encapsulated inside IPv4 packets to cross parts of the network that only speak IPv4 (and vice versa), then decapsulated at the far end.
A dual-stack host prefers IPv6 when both an IPv4 and an IPv6 address resolve for a destination. If the host's IPv6 address itself is fine but the path beyond the first router is broken - a dead tunnel, a misconfigured upstream, an IPv6 default route that silently blackholes - every single connection attempt tries IPv6 first, gets no response, and has to time out before falling back to IPv4. Modern "Happy Eyeballs" logic shortens that fallback to a couple hundred milliseconds in the best case, but a fully blackholed path (packets vanish with no ICMP unreachable at all, rather than being cleanly rejected) can stall each new connection for several seconds. The symptom operators see is not "the site is down" but "everything is randomly slow," which is far harder to diagnose - the fix is usually to verify actual end-to-end IPv6 reachability (not just that the host has an address) before enabling it broadly.