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
- Leading zeros in any group can be dropped:
0db8→db8,0a00→a00,0000→0. - 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.
| Step | Address |
|---|---|
| Full | 2001: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:
0a00becomesa00, nota. And2001:db8::a00::1is 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.
| Bits | Usually | Example in 2001:db8:acad:10::1/64 |
|---|---|---|
| First 48 | Global routing prefix from your ISP | 2001:db8:acad |
| Next 16 | Subnet ID: you choose it | 10 |
| Last 64 | Interface 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::/32is reserved for documentation and examples, like192.0.2.0/24in IPv4. You will see it in exam questions, books and this course.