Part 2 · Addresses and routing
IPv6 explained: addresses, NDP, SLAAC and dual stack
Course contents
In the IPv4 lesson you saw that IPv4 has only about 4.3 billion addresses and ran out years ago, and in the routing lesson you saw NAT, the workaround that lets a whole home share one address. IPv6 is the real fix: a new version of IP with so many addresses that every device can have its own public one again.
The good news: almost everything you have learned still holds. Packets, routing tables, the default gateway, the network part and the host part all work the same way, and TCP, UDP and DNS on top don’t care which version of IP carries them. What changes is the shape of the addresses, how a machine finds its neighbors (no more ARP) and how it gets an address automatically. About half of Google’s traffic runs over IPv6 today, and most mobile networks are IPv6-first, so it is no longer optional.
IPv6 addresses
- An IPv6 address is 128 bits, four times as long as IPv4. Writing that in decimal would be unreadable, so it’s written in hexadecimal: digits
0–9anda–f, where each hex digit stands for 4 bits. The address is eight groups of four hex digits (16 bits each), separated by::2001:0db8:0000:0000:0000:ff00:0042:8329. - The shortening rules (RFC 5952):
- Leading zeros in each group are dropped:
0db8becomesdb8. - One run of consecutive all-zero groups is replaced with
::(only once per address):2001:db8::ff00:42:8329. - Letters are written in lowercase.
- Leading zeros in each group are dropped:
- In a URL the address goes in square brackets:
http://[2001:db8::1]:8080/.
The idea of a network part and a host part from lesson 4 is the same, with one simplification: on a local network, the split is always in the middle. The first 64 bits identify the network and the last 64 bits, the interface ID, identify the machine, so every subnet (every LAN) is a /64. Organizations usually get a /48 from their provider (room for 65,536 LANs) and homes a /56 or a /60. Nobody counts addresses in IPv6: one /64 alone holds 2⁶⁴ addresses: the size of the whole IPv4 Internet, squared.
Address types
| Prefix | Type | Notes |
|---|---|---|
2000::/3 | Global unicast (GUA) | Public address, routable on the Internet |
fc00::/7 (in practice fd00::/8) | Unique local (ULA) | Like IPv4 private addresses; RFC 4193 |
fe80::/10 | Link-local | Automatic on every interface; this link only; used by NDP and routing |
ff00::/8 | Multicast | ff02::1 all nodes on the link, ff02::2 all routers on the link |
::1/128 | Loopback | The equivalent of 127.0.0.1 |
::/128 | Unspecified | The equivalent of 0.0.0.0 |
::ffff:0:0/96 | IPv4-mapped | IPv4 in IPv6 sockets, e.g. ::ffff:192.0.2.1 |
64:ff9b::/96 | NAT64 | Translation to IPv4 |
2001:db8::/32 | Documentation | For examples |
- There is no broadcast. Everything broadcast used to do is done with multicast.
- Every interface has several addresses at once: one link-local, one or more global, maybe a ULA. That is normal.
- The same link-local address can exist on several interfaces, so you must name the interface:
ping fe80::1%eth0.
Interface ID: how an address is built
The lower 64 bits of the address are the interface ID:
- EUI-64 (old): derived from the MAC address. This was a privacy problem, because the device could be tracked across every network it joined.
- Stable privacy (RFC 7217): stable within each network, but not trackable from one network to the next.
- Temporary addresses / privacy extensions (RFC 8981): short-lived random addresses for outgoing connections. The default on desktop and mobile operating systems.
The IPv6 header
The header is a fixed 40 bytes and simpler than the IPv4 header: Version, Traffic Class, Flow Label, Payload Length, Next Header (the equivalent of Protocol), Hop Limit (the equivalent of TTL), and the source and destination addresses. The important differences:
- No checksum. The link and transport layers are enough, and routers work faster without it.
- Routers don’t fragment. Only the sender can, using an extension header. PMTUD is mandatory, and the minimum MTU is 1280 bytes.
- Options moved into chained extension headers (Hop-by-Hop, Routing, Fragment, ESP and others).
NDP: the replacement for ARP, and more
The Neighbor Discovery Protocol (RFC 4861) runs on top of ICMPv6:
| Message | What it does |
|---|---|
| Neighbor Solicitation (NS) | “What is the MAC of this IP?” Like an ARP Request, but multicast, not broadcast |
| Neighbor Advertisement (NA) | The answer (like an ARP Reply) |
| Router Solicitation (RS) | “Is there a router here?” |
| Router Advertisement (RA) | Announces the prefix, default gateway (its link-local address), MTU, and SLAAC vs. DHCPv6 |
| Redirect | A better route |
NDP also performs Duplicate Address Detection (DAD): before using an address, a host asks whether anyone else already has it.
Autoconfiguration: SLAAC and DHCPv6
- SLAAC (Stateless Address Autoconfiguration, RFC 4862): the host takes the
/64prefix from the RA and appends its own interface ID. No server involved. - DHCPv6: like DHCP, with a server. In stateless mode it only hands out information such as DNS servers; in stateful mode it hands out addresses too.
- Flags in the RA decide which one is used:
M(Managed: addresses come from DHCPv6) andO(Other: only configuration comes from DHCPv6). DNS servers can also be announced directly in the RA (RDNSS, RFC 8106). - The default gateway always comes from the RA, never from DHCPv6.
- DHCPv6 Prefix Delegation (DHCPv6-PD): the ISP gives the home router a prefix (for example a
/56), and the router splits it into/64s for its LANs.
ip -6 addr show dev eth0 # note: usually MORE than one address
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...
inet6 2001:db8:1234:abcd:1a2b:3c4d:5e6f:7a8b/64 scope global dynamic
inet6 2001:db8:1234:abcd:9f8e:7d6c:5b4a:3928/64 scope global temporary dynamic
inet6 fe80::1a2b:3c4d:5e6f:7a8b/64 scope link
Three addresses on one interface, and that is perfectly normal: a stable global address, a temporary global address (privacy extensions, used for outgoing connections), and a link-local address (fe80::) that is always there.
ip -6 route # the IPv6 routing table
2001:db8:1234:abcd::/64 dev eth0 proto ra metric 100
fe80::/64 dev eth0 proto kernel metric 256
default via fe80::1 dev eth0 proto ra metric 100
The default gateway is a link-local address (fe80::1), and proto ra means it came from a router advertisement, not from DHCPv6. This trips up a lot of people.
ip -6 neigh # neighbor cache (the IPv6 "ARP table", filled by NDP)
rdisc6 eth0 # (ndisc6 package) send a Router Solicitation, print the RA
ping -6 -c2 google.com
Don’t block ICMPv6
In IPv6, ICMPv6 is part of how the network fundamentally works: NDP, RA, PMTUD and DAD are all ICMPv6. A firewall that blocks all ICMPv6 breaks IPv6. At a minimum, types 1 to 4 (errors, including Packet Too Big), 128 and 129 (Echo) and 133 to 137 (NDP) must be allowed (RFC 4890).
Migration and coexistence with IPv4
- Dual stack: the most common approach; every host has both IPv4 and IPv6. DNS returns both an A and an AAAA record for a name.
- Happy Eyeballs (RFC 8305): the client tries both at nearly the same time (with a slight preference for IPv6) and keeps whichever connects first. Without it, a broken IPv6 path means delays of several seconds.
- NAT64 + DNS64: the network is IPv6-only. For IPv4-only sites, DNS64 synthesizes an AAAA record inside
64:ff9b::/96, and NAT64 does the translation. 464XLAT completes the picture for applications that only speak IPv4; many mobile operators run exactly this. - Tunnels (6in4, 6rd and others) carry IPv6 across IPv4-only networks; they are less common today.
The first of these mistakes, which address a server listens on, will make full sense after the next lesson, where you write servers with sockets.