Chapters

IPv6

Chapter 2 ended with IPv4 running out of addresses, and chapter 10 showed NAT as the workaround. IPv6 is the permanent fix. This chapter covers its addresses, how devices configure themselves without DHCP, how it replaces ARP and broadcast, and how it runs alongside IPv4 today.

Network building blocks · chapter 30 of 34 · 9 min read

Why IPv6

IPv4's 4.3 billion addresses ran out years ago: the regional registries, including APNIC for Asia-Pacific, handed out their last normal blocks in the early 2010s. IPv6 fixes this permanently with 128-bit addresses: about 3.4 × 1038. That is enough to give every device on Earth billions of addresses.

#IPv4 (chapter 2)IPv6
1Size32 bits128 bits
2Addresses~4.3 × 109~3.4 × 1038
3Written as4 decimal numbers with dots8 hex groups with colons
4Sharing addressesNAT everywhere (chapter 10)Not needed: every device gets public addresses
5Getting an addressDHCP (chapter 27)Usually self-configured (SLAAC, section 7)
6Finding MACsARP broadcast (chapter 9)NDP with multicast (section 8)
7BroadcastYesNone: multicast replaces it
8Header20-60 bytes, with a checksumFixed 40 bytes, no checksum (section 9)
Adoption is well under way: a large share of Google's users now reach it over IPv6 (a bit under half at the time of writing), and many mobile networks run mostly on IPv6.

Writing an address

An IPv6 address is 128 bits, written as eight groups of four hex digits (chapter 7's hex), separated by colons. Each group is 16 bits: 8 × 16 = 128.

20010db8000000000000ff0000428329
first 64 bits: the network (prefix)last 64 bits: the interface (host part)
The same network / host split as chapter 3, with a fixed boundary: almost every IPv6 network is a /64. 2001:db8::/32 is reserved for documentation, like 203.0.113.0/24 in IPv4, so it is used for all examples here.

Shortening addresses

Two rules make addresses much shorter:

RuleResult
0Full form2001:0db8:0000:0000:0000:ff00:0042:8329
1Drop leading zeros in each group2001:db8:0:0:0:ff00:42:8329
2Replace one run of all-zero groups with ::2001:db8::ff00:42:8329
:: may appear only once: with two, you could not tell how many zero groups each one stands for. The standard short form uses the longest zero run, lowercase letters, and never uses :: for a single zero group.

Try any address. The tool expands, shortens, and tells you what kind of address it is:

Full form
2001:0db8:0000:0000:0000:ff00:0042:8329
Short form
2001:db8::ff00:42:8329
Type
Documentation (2001:db8::/32) · reserved for examples; a global-unicast-style address
  1. 20010010 0000 0000 0001
  2. 0db80000 1101 1011 1000
  3. 00000000 0000 0000 0000
  4. 00000000 0000 0000 0000
  5. 00000000 0000 0000 0000
  6. ff001111 1111 0000 0000
  7. 00420000 0000 0100 0010
  8. 83291000 0011 0010 1001

Teal: the first 64 bits (network prefix of a /64). Highlighted: the last 64 bits (interface ID). Each group is 16 bits.

Prefixes: how addresses are handed out

IPv6 uses CIDR just like IPv4 (chapter 3), but the numbers are huge. An ISP gives each customer a whole block, and the customer cuts it into /64 networks:

#PrefixWhoContains
12001:db8:5c00::/48Kadé office, from LankaNet65,536 networks of /64
22001:db8:5c00:1::/64Staff network (like 172.16.1.0/24)264 ≈ 18 billion billion addresses
32001:db8:5c00:2::/64Warehouse network (like 172.16.2.0/24)same
42001:db8:4a1:1100::/56Your home, from your ISP256 networks of /64
Nobody counts hosts in IPv6. A /64 per network is standard because self-configuration (section 7) needs a 64-bit host part. The 4th group is a natural "subnet number": 1 = staff, 2 = warehouse.

Address types

#TypeStarts withMeaningIPv4 equivalent
1Global unicast2000::/3 (2… or 3…)Public, routable on the internetpublic addresses
2Link-localfe80::/10Valid only on the local link, never routed. Every IPv6 interface creates one automatically.169.254.x.x, but always present
3Unique local (ULA)fc00::/7 (in practice fd…)Private addresses for internal use10.x, 172.16.x, 192.168.x
4Multicastff00::/8One sender to a group. ff02::1 = all devices on the link; ff02::2 = all routers.replaces broadcast
5Loopback::1This machine127.0.0.1
6Unspecified::"No address yet" / "all interfaces" when listening0.0.0.0
7IPv4-mapped::ffff:0:0/96An IPv4 address inside an IPv6 socket, e.g. ::ffff:192.168.1.23-
IPv6 has no broadcast. Jobs that used broadcast in IPv4 (ARP, DHCP Discover) use multicast groups instead, so only interested devices are disturbed. Anycast (chapter 12) exists too; it looks like a normal unicast address.

One interface, several addresses

In IPv4 your WiFi interface had one address. In IPv6 it normally has several at once, each with a job:

$ ifconfig en0 | grep inet6
inet6 fe80::a683:e7ff:fe2b:910c%en0 prefixlen 64 scopeid 0x6        ← link-local
inet6 2001:db8:5c00:1:8a2f:31c4:77be:d201 prefixlen 64 autoconf secured  ← stable global
inet6 2001:db8:5c00:1:e91a:4c03:1f55:9a3b prefixlen 64 autoconf temporary ← temporary global
  • Link-local for talking to the router and neighbours, including the gateway itself (routers are usually reached by their link-local address).
  • Stable global for incoming connections, the same whenever you join this network.
  • Temporary global, changed every day or so, used for outgoing connections so websites cannot track the device by its address ("privacy addresses").

Self-configuration: SLAAC

IPv6 devices usually configure themselves, with no DHCP server. This is SLAAC (stateless address autoconfiguration). The front desk PC joining the staff network:

Front desk PCOffice routerthe PC joins the staff network and makes its link-local address fe80::…DAD: "does anyone already use this address?" (multicast)no answer within about a second: the address is freeRouter Solicitation → ff02::2 (all routers)Router Advertisement: prefix 2001:db8:5c00:1::/64, "I am your gateway"the PC builds 2001:db8:5c00:1:(interface ID) and runs DAD againdone: a global address, and a default route via the router's fe80:: address

The interface ID (the last 64 bits) can be made two ways:

From the MAC (EUI-64)Take the 48-bit MAC, insert ff:fe in the middle, and flip the "locally set" bit from chapter 7. The laptop's a4:83:e7:2b:91:0c becomes a683:e7ff:fe2b:910c. Easy, but the same on every network, so it can be used to track the device. Older systems and many routers still use it.
Random (privacy / stable)What laptops and phones use for global addresses today: random-looking, stable per network or changing daily.
#StepResult
1Split the MAC in halfa4:83:e7 | 2b:91:0c
2Insert ff:fe in the middle (48 → 64 bits)a4:83:e7:ff:fe:2b:91:0c
3Flip bit 7 of the first byte (the U/L bit, chapter 7)10100100 → 10100110 · a4 → a6
4Interface ID (4 groups)a683:e7ff:fe2b:910c
5Link-local addressfe80::a683:e7ff:fe2b:910c
6Global address on the staff /64 (if EUI-64 were used)2001:db8:5c00:1:a683:e7ff:fe2b:910c

Anyone who sees the global address can read your MAC back out of it, on every network you join. That is why laptops and phones use random interface IDs for global addresses.

NDP: ARP's replacement

IPv6 finds MAC addresses with NDP (Neighbor Discovery Protocol), which runs over ICMPv6. Instead of broadcasting to everyone like ARP, it sends a Neighbor Solicitation to a special multicast group derived from the target's address (the "solicited-node" group, ff02::1:ff + the last 24 bits). Only devices whose address ends the same way listen, which in practice is almost always just the target.

#IPv4 (chapters 9, 27)IPv6 with NDP (ICMPv6)
1ARP request, broadcast "who has 172.16.1.20?"Neighbor Solicitation, to the target's solicited-node multicast group
2ARP replyNeighbor Advertisement
3Gateway from DHCPRouter Advertisement: routers announce themselves and the prefix
4ARP check for a duplicate addressDuplicate Address Detection (DAD)
5ICMP redirectICMPv6 Redirect
So ICMPv6 is not optional: block it and IPv6 stops working entirely (no neighbours, no routers, no path MTU discovery). Firewalls must allow the ICMPv6 types NDP and PMTUD need. Like ARP, NDP trusts what it hears: fake Router Advertisements are the IPv6 version of a rogue DHCP server (chapter 27), and managed switches offer "RA Guard" against them.

A simpler header

The IPv6 header is a fixed 40 bytes, and has fewer fields than IPv4's (chapter 12):

bit →08162431bytes 0-3Ver4Traffic class8Flow label20bytes 4-7Payload length16Next header8Hop limit8bytes 8-23Source address128 bits (4 rows)bytes 24-39Destination address128 bits (4 rows)thenExtension headers (optional), then TCP / UDP / ICMPv6

Compare chapter 12’s IPv4 header: no IHL (always 40 bytes), no ID/flags/offset (no router fragmentation), no checksum, and no options in the main header. The addresses take 32 of the 40 bytes.

No header checksumLinks (FCS) and TCP/UDP already check for errors, so routers no longer recompute a checksum every hop. This is why the UDP checksum becomes mandatory (chapter 15).
No fragmentation by routersOnly the sender may fragment; routers send ICMPv6 "Packet Too Big" instead (chapter 18). Every IPv6 link must carry at least 1,280 bytes.
Extension headersOptions, fragmentation info and more move into optional headers chained by the Next Header field, which otherwise says TCP (6), UDP (17) or ICMPv6 (58).
Hop LimitIPv4's TTL, renamed to say what it really counts (chapter 12)
Flow LabelMarks packets of one flow so routers can keep them on the same path (ECMP, chapter 12)

No NAT: end-to-end again

With addresses to spare, every device gets its own public address and no NAT is needed. The front desk PC and the packing PC reach kade-api with their own addresses, and chapter 10's port limits and "lost device in the logs" problems disappear.

Living with both: dual stack

The internet is in a long transition. Most devices run dual stack: IPv4 and IPv6 at the same time.

DNSA name can have A and AAAA records (chapter 23). A dual-stack client asks for both.
Happy EyeballsThe client tries IPv6 first and starts IPv4 a fraction of a second later; whichever connects first wins. A broken IPv6 path then costs only a tiny delay.
NAT64 + DNS64Many mobile networks give phones only IPv6. To reach IPv4-only sites, the carrier's DNS invents an AAAA record that points to a translator (NAT64), which converts to IPv4. The rider's phone may reach an IPv4-only api.kade.lk this way.
TunnelsOlder ways to carry IPv6 inside IPv4 packets across networks that only speak IPv4 (6in4 and similar)

IPv6 in the Kadé setup

Public entryGCP's external load balancers can take an IPv6 address. Add an AAAA record for api.kade.lk pointing to it, and IPv6 users connect natively, even if everything behind the load balancer stays IPv4.
Inside the VPCGCP subnets can be dual-stack: each /64 IPv6 range sits beside the IPv4 range, internal (ULA) or external. VMs then get an IPv6 address too.
FirewallsIPv6 needs its own rules: a rule for 0.0.0.0/0 does not cover ::/0. Check both.
URLs and logsAddresses in URLs go in brackets because of the colons: https://[2001:db8::1]:443/. Link-local addresses need the interface: fe80::1%en0. Log parsers and allowlists written for IPv4 often break on these.

Summary

#IdeaIn one lineNew terms
1-2IPv6128 bits, 8 hex groups; /64 networks: 64-bit prefix + 64-bit interface IDIPv6, interface ID
3ShorteningDrop leading zeros; one :: for the longest zero run
4PrefixesISPs hand out /48 or /56; each network is a /64prefix delegation
5-6TypesGlobal, link-local, ULA, multicast, ::1, ::; several per interface; no broadcastlink-local, ULA, privacy address
7SLAACRouter Advertisements give the prefix; the device builds its own address; DHCPv6 optionalSLAAC, RA, EUI-64, DHCPv6
8NDPARP's replacement over ICMPv6 multicast; ICMPv6 must not be blockedNDP, DAD, RA Guard
9HeaderFixed 40 bytes; no checksum; no router fragmentation; extension headersNext Header, Hop Limit, Flow Label
10-11TransitionNo NAT but a firewall; dual stack; Happy Eyeballs; NAT64/DNS64dual stack, NAT64
12KadéIPv6 load balancer + AAAA; dual-stack subnets; separate ::/0 rules

Try it yourself

Your IPv6 addresses

  • What to look for: A fe80:: address always; global ones if your ISP gives IPv6.
  • Runs on: macOS · Linux: ip -6 addr · Windows: ipconfig
  • From section: 6. One interface, several addresses
ifconfig en0 | grep inet6

Your public IPv6 and IPv4 addresses

  • Steps: curl -6 https://ifconfig.co and curl -4 https://ifconfig.co
  • What to look for: If -6 fails, your network has no working IPv6.
  • From section: 11. Living with both: dual stack
curl -6 https://ifconfig.cocurl -4 https://ifconfig.co

An IPv6 DNS record

dig AAAA google.com +short

Every IPv6 device on your link answers

  • What to look for: Replies from several fe80:: addresses, including the router.
  • Runs on: macOS · Linux: ping -6 ff02::1%eth0
  • From section: 5. Address types
ping6 ff02::1%en0

The NDP neighbour table (ARP's replacement)

  • What to look for: IPv6 addresses with MACs, the router marked as router.
  • Runs on: macOS · Linux: ip -6 neigh
  • From section: 8. NDP: ARP's replacement
ndp -a

IPv6 routes

  • What to look for: default via fe80::… : the gateway is a link-local address.
  • Runs on: Linux · macOS: netstat -rn -f inet6
  • From section: 7. Self-configuration: SLAAC
ip -6 route

A full dual-stack check

test-ipv6.com

Spotted a mistake, or something unclear? Suggest an edit on GitHub