An IPv6 address is 128 bits long, written as eight groups of four hexadecimal digits separated by colons, where each group represents 16 bits. Addresses can be written in lowercase or uppercase. The preferred format is x:x:x:x:x:x:x:x, where each x is a group of four hexadecimal digits. Each such group is called a hextet — so a single hextet is 16 bits, or four hexadecimal digits, and a full address is eight hextets (32 hexadecimal digits in total).
The Range of IPv6 Addresses
IPv6 addresses run from 0000:0000:0000:0000:0000:0000:0000:0000 to FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF. This is expressed in hexadecimal, and each hextet maps to 16 binary bits — for example, the hextet 0000 equals 0000000000000000 (sixteen 0s), and FFFF equals 1111111111111111 (sixteen 1s).
Since IPv6 is written in hexadecimal, it helps to keep the relationship between binary, decimal, and hexadecimal clear:
| Decimal | Binary | Hexadecimal |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 3 |
| 4 | 0100 | 4 |
| 5 | 0101 | 5 |
| 6 | 0110 | 6 |
| 7 | 0111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| 10 | 1010 | A |
| 11 | 1011 | B |
| 12 | 1100 | C |
| 13 | 1101 | D |
| 14 | 1110 | E |
| 15 | 1111 | F |
A full IPv6 address in preferred format looks like the examples below. Each is eight hextets, written out with all leading zeros in place:
2001:0000:0000:1111:1234:1000:A000:0100
2001:0DA1:B111:0000:0000:ABCD:0BCD:1245
FE80:0000:2BCD:0000:1234:4567:89AB:CDEF
FE80:8BAB:0000:0000:0000:0000:0000:0123
FF02:0000:0000:0000:0000:0000:0000:0001
FE02:0000:ABBB:0000:0000:0001:FF00:0200
0000:0000:0000:0000:0000:0000:0000:0001
0000:0000:0000:0000:0000:0000:0000:0000
Writing addresses out in full like this is correct but verbose. Two rules, defined in RFC 4291 and refined in RFC 5952, let us shorten them.
Shortening IPv6 Addresses
Rule 1 — Omitting Leading Zeros
The first rule is to omit the leading zeros in any hextet. This removes only leading zeros, never trailing ones — otherwise the address would become ambiguous.
0100can be written as1000DA1can be written asDA10123can be written as1230000can be written as0
Applying this rule to the preferred-format examples above gives the following. Note how trailing zeros are kept (1000 and A000 stay intact, 0200 becomes 200 not 2):
| Preferred Format | Omitting Leading 0s |
|---|---|
2001:0000:0000:1111:1234:1000:A000:0100 | 2001:0:0:1111:1234:1000:A000:100 |
2001:0DA1:B111:0000:0000:ABCD:0BCD:1245 | 2001:DA1:B111:0:0:ABCD:BCD:1245 |
FE80:0000:2BCD:0000:1234:4567:89AB:CDEF | FE80:0:2BCD:0:1234:4567:89AB:CDEF |
FE80:8BAB:0000:0000:0000:0000:0000:0123 | FE80:8BAB:0:0:0:0:0:123 |
FF02:0000:0000:0000:0000:0000:0000:0001 | FF02:0:0:0:0:0:0:1 |
FE02:0000:ABBB:0000:0000:0001:FF00:0200 | FE02:0:ABBB:0:0:1:FF00:200 |
0000:0000:0000:0000:0000:0000:0000:0001 | 0:0:0:0:0:0:0:1 |
0000:0000:0000:0000:0000:0000:0000:0000 | 0:0:0:0:0:0:0:0 |
Rule 2 — Replacing a Run of Zeros with a Double Colon
The second rule uses a double colon (::) to replace a single, contiguous run of one or more all-zero hextets. The :: can be used only once in an address — using it twice would make the result ambiguous, because there would be more than one way to expand it back.
For example, given FE02:0000:ABBB:0000:0000:0001:FF00:0200, you cannot write FE02::ABBB::1:FF00:200 — that uses :: twice and is invalid.
Combining both rules (omitting leading zeros and using :: for the longest zero run) produces the compressed format. Applying it to the addresses from the table above:
| Omitting Leading 0s | Compressed Address |
|---|---|
2001:0:0:1111:1234:1000:A000:100 | 2001::1111:1234:1000:A000:100 |
2001:DA1:B111:0:0:ABCD:BCD:1245 | 2001:DA1:B111::ABCD:BCD:1245 |
FE80:0:2BCD:0:1234:4567:89AB:CDEF | FE80::2BCD:0:1234:4567:89AB:CDEF |
FE80:8BAB:0:0:0:0:0:123 | FE80:8BAB::123 |
FF02:0:0:0:0:0:0:1 | FF02::1 |
FE02:0:ABBB:0:0:1:FF00:200 | FE02:0:ABBB::1:FF00:200 |
0:0:0:0:0:0:0:1 | ::1 |
0:0:0:0:0:0:0:0 | :: |
Two rows above are worth studying, because they show the “use :: only once” rule in action:
FE80::2BCD:0:1234:4567:89AB:CDEF— the address has two separate single-zero hextets. Only the first is replaced with::; the later0is left as0, because::can’t appear twice.FE02:0:ABBB::1:FF00:200— the run of two zeros (positions 4–5) becomes::, while the single0at position 2 stays0. You compress the longer run, not the isolated zero.
Common Mistakes in IPv6 Shortening
1. Using :: more than once
The :: may appear only once, replacing a single run of consecutive zeros.
- Wrong:
2001::db8::1(two::) - Right:
2001:db8::1
2. Not compressing the longest zero run
RFC 5952 requires replacing the longest run of consecutive zero groups. If two runs are the same length, compress the leftmost one.
- Original:
2001:0db8:0000:0000:0000:ff00:0042:8329 - Wrong:
2001:db8:0::ff00:42:8329(compressed only one group instead of three) - Right:
2001:db8::ff00:42:8329(the run0000:0000:0000→::)
3. Truncating trailing zeros (not just leading ones)
You may remove leading zeros in a hextet, but never trailing zeros — that changes the value.
- Wrong:
abc0→abc(this changesABC0into0ABC, a different value) - Wrong:
0370→037(drops a trailing zero — invalid) - Right:
0370→370(drops only the leading zero — valid) - Right:
fe80:0000:0000:0000:0000:0000:0000:0001→fe80::1(writingfe80::0:1instead adds an unnecessary zero)
4. Invalid placement or extra colons
The :: replaces one or more full 16-bit zero groups; you can’t stack extra colons.
- Wrong:
3ffe:0500:0000:0000:0000:0000:0000:0001→3ffe:500::::1(too many colons) - Right:
3ffe:500::1
5. Trying to compress non-consecutive zeros
:: compresses only consecutive zero groups, not scattered ones.
- Original:
2001:0:0:ff00:0:0:0:1 - Wrong:
2001::ff00::1(two::) - Right:
2001::ff00:0:0:1(compress the leftmost run; the later zeros stay as0)
6. Over-compressing a single zero group
A single zero hextet is written as 0, not ::.
- Wrong:
2001:0db8:0:0:1:0:0:1→2001:db8::1::1(two::) - Right:
2001:db8:0:0:1::1
7. Misrepresenting the special addresses
The loopback (::1) and unspecified (::) addresses have fixed forms.
- Wrong:
0:0:0:0:0:0:0:1→::::::1 - Right:
::1
Best Practices Summary
- Use
::once, on the longest consecutive zero run. - Remove leading zeros in a hextet (
0db8→db8). - Keep trailing zeros (
abc0staysabc0). - For equal-length zero runs, compress the leftmost.
- Validate shortened addresses with a trusted IPv6 tool if unsure.
Valid vs. Invalid Shortening at a Glance
| Original Address | Invalid Shortening | Correct Shortening |
|---|---|---|
2001:0db8:0000:0000:0000:ff00:0042:8329 | 2001:db8:0::ff00:42:8329 | 2001:db8::ff00:42:8329 |
fe80:0000:0000:0000:0000:0000:0000:0001 | fe80::0:1 | fe80::1 |
3ffe:0500:0000:0000:0000:0000:0000:0001 | 3ffe:500::::1 | 3ffe:500::1 |
0000:0000:0000:0000:0000:0000:0000:0001 | ::0:1 | ::1 |
Following these rules and RFC 5952 keeps your IPv6 representation accurate and unambiguous.
Prefix Length Notation
The leftmost bits of an IPv6 address, expressed in CIDR format, are the network prefix — the IPv6 equivalent of an IPv4 subnet mask. The notation uses a value from 1 to 128 to indicate how many bits belong to the network portion.
For example, in 2001:ABC8:1000:000C:0000:0000:0000:0001/64, the prefix 2001:ABC8:1000:000C::/64 is the network, and the range for this network runs from 2001:ABC8:1000:000C:0000:0000:0000:0000/64 to 2001:ABC8:1000:000C:FFFF:FFFF:FFFF:FFFF/64.
In that address, the first three hextets (48 bits) 2001:ABC8:1000 are the global routing prefix, the next 16 bits (000C) are used for subnetting within the organization, and the final 64 bits identify individual hosts. The prefix length tells you how many bits of a global unicast address make up the network portion.
Network administrators typically choose prefix lengths that are multiples of four, since each additional 4 bits shifts the network boundary exactly one hexadecimal digit to the right — which is easy to reason about without a subnet calculator. The table below shows common prefix lengths and the number of addresses each contains. (The total is calculated as 2^(128 − prefix length).)
| Prefix Length | Network Portion Example | Total Addresses (2^(128 − n)) | Notes |
|---|---|---|---|
| /3 | 2000::/3 | 2¹²⁵ | The global unicast address (GUA) block — the range currently assigned for public IPv6. |
| /16 | 2001::/16 | 2¹¹² | Blocks assigned to Regional Internet Registries (RIRs). |
| /32 | 2001:db8::/32 | 2⁹⁶ | Documentation/example prefix reserved by RFC 3849. |
| /48 | 2001:db8:1234::/48 | 2⁸⁰ | Common assignment to an organization (supports 65,536 /64 subnets). |
| /64 | 2001:db8:1234:5678::/64 | 2⁶⁴ | Standard subnet size for an end network (required for SLAAC). |
| /128 | ::1/128 | 1 (2⁰) | A single host — for example, the loopback address ::1. |
Key Notes
- Global unicast range. Public IPv6 unicast addresses come from
2000::/3. You’ll often see individual allocations written with longer prefixes (a /32 to an ISP, a /48 to an organization, a /64 to a LAN), all carved out of that /3 block. - Total addresses. The count for any prefix is 2 raised to the number of host bits, i.e. 2^(128 − prefix length). For a /64, that’s 2⁶⁴ addresses per subnet; for a /48, 2⁸⁰.
- Special cases.
/64is the standard (and, for SLAAC, required) subnet size for end networks, and/128denotes a single host such as the loopback::1.
FAQs
What is the preferred format for IPv6 addresses?
Eight groups (hextets) of four hexadecimal digits each, separated by colons — for example, 2001:0db8:0000:0000:0000:0000:0000:0001. All leading zeros are shown. This is the fully expanded, unambiguous form.
How can IPv6 addresses be compressed?
Two rules: omit the leading zeros in each hextet (0db8 → db8), and replace one contiguous run of all-zero hextets with ::. The :: can be used only once per address.
Why is IPv6 compression important?
It makes long addresses far easier to read, write, and manage, while RFC 5952’s rules ensure everyone compresses the same address the same way — avoiding ambiguity.
Can :: be used more than once in an address?
No. It may appear only once, because a second :: would make it impossible to know how many zero groups each one represents. Compress the longest run (leftmost, if there’s a tie) and leave any other single zeros as 0.
What prefix length is typical for a host’s subnet?
/64 is the standard subnet size for end networks. The first 64 bits are the network prefix (global routing prefix plus subnet ID) and the last 64 bits are the interface identifier (host portion). A host address like 2001:db8:abcd:1234::1 sits in the 2001:db8:abcd:1234::/64 network. Shorter prefixes such as /32 or /48 are allocated to ISPs and organizations for further subnetting.
How does IPv6 handle multicast?
IPv6 replaces IPv4’s broadcast with multicast: packets destined for a multicast address (in the FF00::/8 range) are delivered to all interfaces that have joined that group.