IPv6
IPv6
The 128-bit Internet Protocol: a /64 prefix for the network, 64 bits for the card.
Written as eight hex groups, leading zeros dropped and one zero run shortened to ::: fd00:0:1::2. A
network's prefix is almost always a /64; the other 64 bits are the interface id. fd00::/8 is unique
local space, IPv6's private range. Beyond size: no broadcast, no ARP (neighbour discovery instead), routers never
fragment, and devices build their own addresses. Names map to IPv6 through AAAA records.
How IPv6 addressing works
An IPv6 address is 128 bits, written as eight groups of four hex digits. RFC 5952 fixes one short form: drop
leading zeros in each group, write the longest run of two or more zero groups once as ::, use lower case. So
fd00:0000:0001:0000:0042:0aff:fe00:010a is written fd00:0:1:0:42:aff:fe00:10a, and fd00:0:1::2 expands back
to eight groups by filling the gap with zeros.
A network's prefix is almost always a /64. The other 64 bits are the interface id, which names the card. A provider delegates a /48 or /56 to a site, so a home has 256 or 65,536 networks of its own. The main kinds of address:
| Range | Kind | Use |
|---|---|---|
2000::/3 |
global unicast | reachable across the internet |
fc00::/7, in practice fd00::/8 |
unique local (ULA) | private, like 10.0.0.0/8 |
fe80::/10 |
link-local | one link only, on every card |
ff00::/8 |
multicast | groups; ff02::1 is every node on the link |
::1 |
loopback | the machine itself |
There is no broadcast in IPv6. What broadcasts did, multicast does.
When a card comes up, this happens:
- It gives itself a link-local address,
fe80::plus an interface id, made from the MAC (EUI-64: the MAC split in two,ff:feinserted, one bit flipped) or chosen at random. - It checks the address is free (duplicate address detection): a neighbour solicitation for its own address,
sent from
::. An answer means someone has it. - It sends a router solicitation (ICMPv6 type 133) to
ff02::2, all routers. - A router answers with a router advertisement (type 134): the prefix, how long it is valid, and "use me as your gateway". Routers also send these unasked, every few minutes.
- The host builds a global address from the prefix and an interface id: SLAAC (RFC 4862). No server keeps a list. Many systems add short-lived random temporary addresses for outgoing connections, for privacy.
- To reach a neighbour, it uses neighbour discovery instead of ARP: a neighbour solicitation (135) to the target's solicited-node multicast group, answered by a neighbour advertisement (136).
What it looks like on a Linux machine
In the IPv6 basics lab the laptop has two IPv6 addresses that nobody typed:
$ ip -6 addr show dev eth0
inet6 fd00:0:1:0:42:aff:fe00:10a/64 scope global dynamic
valid_lft 86394sec preferred_lft 14394sec
inet6 fe80::42:aff:fe00:10a/64 scope link
valid_lft forever preferred_lft forever
Both end with the same interface id, made from the card's MAC. The global one came from a router advertisement, and so did the default route, which points at the router's link-local address:
$ ip -6 route show default
default via fe80::42:aff:fe00:102 dev eth0 proto ra metric 1024 expires 1797sec hoplimit 64 pref medium
A link-local address needs a zone to be usable, because every card has one: ping fe80::42:aff:fe00:10b%eth0.
ip -6 neigh is the neighbour table, with the same REACHABLE and STALE states as IPv4.
tcpdump 'icmp6 and ip6[40] == 134' waits for a router advertisement and decodes its prefix. The
IPv6 addressing lab works through prefixes and shortening by hand, and the
dual-stack lab runs IPv6 beside IPv4 across a router.
What goes wrong, and how you see it
Only a link-local address. No router advertisement arrived: no router, a router not sending them, or a firewall dropping ICMPv6. Blocking ICMPv6 the way people block ICMP in IPv4 breaks IPv6 outright, since neighbour discovery, router discovery and path MTU discovery all use it.
fe80 without a zone. ping fe80::… alone fails with an invalid argument on a machine with more than one card.
A rogue router advertisement. Any host can send one and become the gateway for everyone who listens, the IPv6 twin of a rogue DHCP server. Switches filter them with RA guard.
Dual-stack surprises. A name with an AAAA record is tried over IPv6 first. If the IPv6 path is broken, every connection waits before falling back to IPv4.
Packets too big. Routers never fragment IPv6. They send ICMPv6 Packet Too Big, and a sender that never sees it stalls on large transfers.
Questions people ask
Why is an IPv6 subnet always a /64? SLAAC and many other mechanisms expect a 64-bit interface id. A /64 holds 2^64 addresses, so there is no reason to save space.
Does IPv6 need NAT or DHCP? Neither is required. Every device can have a global address, and SLAAC configures it. DHCPv6 exists for networks that want to hand out addresses or options centrally.
How many IPv6 addresses are there? 2^128, about 3.4 × 10^38.