Understanding IPv6 Format: Hexadecimal Blocks and Shorthand Rules
A comprehensive guide to 128-bit IPv6 addressing. Understand how eight 16-bit hextets are structured, master leading zero compression, and learn the strict RFC 5952 rules for unambiguous shorthand notation.
Quick Answer
An IPv6 address is 128 bits long, divided into eight 16-bit hexadecimal blocks (hextets) separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334). Under RFC 5952, addresses are simplified using two mandatory rules: leading zeros within any hextet must be suppressed, and the longest contiguous run of all-zero hextets must be compressed into a single double-colon (::).
- Total Capacity: 2^128 = 3.4 x 10^38 addresses (enough to assign billions of IPs to every atom on Earth).
- Shorthand Rule 1: Leading zeros are optional (e.g., :0001: becomes :1:).
- Shorthand Rule 2: A single double colon (::) compresses consecutive zero hextets, but can only be used once.
1. The 128-Bit Hexadecimal Block Structure
Unlike IPv4's decimal octets (base 10), IPv6 uses hexadecimal notation (base 16) consisting of digits 0-9 and letters a-f. Each hexadecimal digit represents exactly 4 binary bits (a nibble):
2. Shorthand Rules: Step-by-Step Compression
Writing 39 characters for a single IP address is cumbersome and prone to typographical errors. The IETF standardized two compression rules:
Rule A: Suppressing Leading Zeros
Within each 16-bit hextet, any leading zeros can and must be removed. However, trailing zeros must never be removed because that changes the numerical value:
:0042:becomes:42::0db8:becomes:db8::0000:becomes:0:(when not using the double colon):ff00:remains:ff00:(trailing zeros preserved)
Rule B: Double Colon (::) Compression
Consecutive sections of all-zero hextets can be replaced by a single double colon (::). For example:2001:db8:0:0:0:0:0:1 → 2001:db8::1
Critical Rule: The double colon can only appear once in an entire address. If you wrote 2001::1::2, a network parser wouldn't know whether the left side had four zeros and the right side had one, or vice-versa.
3. IPv6 Compression Transformation Matrix
Examine how different special-purpose and unicast IPv6 addresses transform from raw uncompressed format into canonical RFC 5952 syntax:
| Address Type | Full Uncompressed Form (128-Bit) | Canonical Compressed Form | Prefix / Scope |
|---|---|---|---|
| Loopback | 0000:0000:0000:0000:0000:0000:0000:0001 | ::1 | ::1/128 (Single host) |
| Unspecified / Any | 0000:0000:0000:0000:0000:0000:0000:0000 | :: | ::/0 (Default route) |
| Link-Local Auto | fe80:0000:0000:0000:0202:b3ff:fe1e:8329 | fe80::202:b3ff:fe1e:8329 | fe80::/10 (Local LAN) |
| Global Unicast | 2001:0db8:0000:0000:0008:0800:200c:417a | 2001:db8::8:800:200c:417a | 2000::/3 (Global WAN) |
| IPv4-Mapped v6 | 0000:0000:0000:0000:0000:ffff:c000:0201 | ::ffff:192.0.2.1 | ::ffff:0:0/96 (Dual-stack) |
IPv6 Shorthand Parsing Decision Tree
[ Parse IPv6 Address String ]
|
+---------------+---------------+
| |
[ Contains '::' ] [ Full 8 Hextets ]
| |
Verify '::' Appears Once e.g. 2001:0db8:0000:0000:...
| |
Expand Omitted Zero Blocks Omit Leading Zeros (RFC 5952)
| |
+--------+--------+ +--------+--------+
| | | |
[ Valid Canonical ] [ Invalid ] [ Valid Canonical ] [ Uppercase ]
2001:db8::1 Two '::' 2001:db8:0:0:... Convert to lowercase
4. Command-Line Inspection of Native IPv6
Inspect your computer's configured IPv6 global unicast and link-local addresses:
# Windows (PowerShell)
Get-NetIPAddress -AddressFamily IPv6 | Where-Object PrefixOrigin -ne 'WellKnown' | Select-Object IPAddress, InterfaceAlias# Linux (Terminal)
ip -6 addr show scope global# macOS (Terminal)
ifconfig | grep "inet6 " | grep -v "fe80::"Frequently Asked Questions
Why can the double colon (::) only appear once in an IPv6 address?
The double colon (::) represents one or more consecutive 16-bit groups of zeros. If it appeared twice in an address (e.g., 2001::1::2), it would be mathematically impossible for a parser to determine how many zero hextets were omitted from each side, creating ambiguity. RFC 5952 strictly mandates that :: can be used at most once, and should replace the longest contiguous run of zeros.
Are IPv6 hexadecimal characters case-sensitive?
In network protocol parsing, hexadecimal characters (a through f) are case-insensitive. However, RFC 5952 explicitly specifies that for canonical text output and consistency, lowercase letters (a, b, c, d, e, f) must always be used.
What is a "hextet" or "quibble"?
A hextet (informally called a quibble or 16-bit block) is one of the eight segments of an IPv6 address. Each hextet contains four hexadecimal digits (4 bits per digit = 16 bits = 2 bytes) separated by colons.
Data & Technical Sources
- IETF RFC 5952 — A Recommendation for IPv6 Address Text Representation
- IETF RFC 4291 — IP Version 6 Addressing Architecture