IPv6 addresses: format and shortening

Why IPv6?

IPv4 has about 4.3 billion addresses, and they ran out years ago. NAT (later in the course) stretched them, but it breaks the idea that every device can be reached directly. IPv6 uses 128-bit addresses: about 3.4 × 1038 of them, enough to give every device on Earth its own public address many times over.

How an address is written

128 bits are written as eight groups of four hexadecimal digits (16 bits each, called hextets), separated by colons:

2001:0db8:0000:0000:0a00:0000:0000:0001

Hex digits go 0-9 then a-f (a = 10 ... f = 15). One hex digit is 4 bits, so four digits make one 16-bit group. Upper or lower case doesn't matter; the convention is lower case.

Two rules to shorten it

  1. Leading zeros in any group can be dropped: 0db8 → db8, 0a00 → a00, 0000 → 0.
  2. One run of consecutive all-zero groups can be replaced by ::. Only once per address, or nobody could tell how many zeros each :: stands for.
StepAddress
Full2001:0db8:0000:0000:0a00:0000:0000:0001
Rule 1 (leading zeros)2001:db8:0:0:a00:0:0:1
Rule 2 (one ::)2001:db8::a00:0:0:1

Here there are two runs of two zero groups. The standard (RFC 5952) says: replace the longest run, and if they are equal, the first one. So the answer is 2001:db8::a00:0:0:1, not 2001:db8:0:0:a00::1 (although both mean the same address).

Common mistake: Trailing zeros are never dropped: 0a00 becomes a00, not a. And 2001:db8::a00::1 is invalid: two ::.

Expanding a short address

Work backwards: count the groups you can see, and the :: fills in the missing ones with zeros until there are eight. fe80::1 has two groups, so :: stands for six: fe80:0000:0000:0000:0000:0000:0000:0001.

Prefixes

IPv6 has no dotted masks; it always uses a prefix length. On a LAN it is almost always /64: the first 64 bits name the network (the prefix), and the last 64 bits are the interface ID, which says which device it is.

BitsUsuallyExample in 2001:db8:acad:10::1/64
First 48Global routing prefix from your ISP2001:db8:acad
Next 16Subnet ID: you choose it10
Last 64Interface ID::1

Remember: With a /48 from your ISP and /64 subnets you have 16 bits of subnet ID: 65,536 subnets, each with 264 addresses. In IPv6 you never run short of host addresses, so you don't do VLSM on LANs.

Tip: 2001:db8::/32 is reserved for documentation and examples, like 192.0.2.0/24 in IPv4. You will see it in exam questions, books and this course.

HOME LABS COMMUNITY DASHBOARD