Looking at the longest representation of an IPv6 address can be overwhelming:
0000:0000:0000:0000:0000:0000:0000:0000
0000:0000:0000:0000:0000:0000:0000:0001
ff02:0000:0000:0000:0000:0000:0000:0001
fe80:0000:0000:0000:a299:9bff:fe18:50d1
2001:0db8:cafe:0001:0000:0000:0000:0200
There are two rules for reducing the notation.
Rule 1: Omit Leading 0s
Omit any leading 0s in any hextet (a 16-bit section). This rule applies only to leading 0s and not trailing 0s. Table 1 shows examples of omitting leading 0s in a hextet:
Table 1 Examples of Omitting Leading 0s in a Hextet (Leading 0s in bold; spaces retained)
Format | IPv6 Address |
Preferred | 0000:0000:0000:0000:0000:0000:0000:0000 |
Leading 0s omitted | 0: 0: 0: 0: 0: 0: 0: 0 or 0:0:0:0:0:0:0:0 |
Preferred | 0000:0000:0000:0000:0000:0000:0000:0001 |
Leading 0s omitted | 0: 0: 0: 0: 0: 0: 0: 1 or 0:0:0:0:0:0:0:1 |
Preferred | ff02:0000:0000:0000:0000:0000:0000:0001 |
Leading 0s omitted | ff02: 0: 0: 0: 0: 0: 0: 1 or ff02:0:0:0:0:0:0:1 |
Preferred | 2001:0db8:1111:000a:00b0:0000:9000:0200 |
Leading 0s omitted | 2001: db8: 1111: a: b0: 0:9000: 200 or 2001:db8:1111:a:b0:0:9000:200 |
Rule 2: Omit All-0s Hextet
Use a double colon (::
) to represent any single, contiguous string of two or more hextets consisting of all 0s. Table 2 shows examples of using the double colon.
Table 2 Examples of Omitting a Single Contiguous String of All-0s Hextets (0s in Bold Replaced By a Double Colon)
Format | IPv6 Address |
Preferred | 0000:0000:0000:0000:0000:0000:0000:0000 |
(::) All-0s segments | :: |
Preferred | 0000:0000:0000:0000:0000:0000:0000:0001 |
(::) All-0s segments | ::0001 |
Preferred | ff02:0000:0000:0000:0000:0000:0000:0001 |
(::) All-0s segments | ff02::0001 |
Preferred | 2001:0db8:aaaa:0001:0000:0000:0000:0100 |
(::) All-0s segments | 2001:0db8:aaaa:0001::0100 |
Preferred | 2001:0db8:0000:0000:abcd:0000:0000:1234 |
(::) All-0s segments | 2001:0db8::abcd:0000:0000:1234 |
Only a single contiguous string of all 0s can be represented by a double colon; otherwise the address would be ambiguous. Consider the following example:
2001::abcd::1234
There are many different possible choices for the preferred address:
2001:0000:0000:0000:0000:abcd:0000:1234
2001:0000:0000:0000:abcd:0000:0000:1234
2001:0000:0000:abcd:0000:0000:0000:1234
2001:0000:abcd:0000:0000:0000:0000:1234
If two double colons are used, you cannot tell which of these addresses is correct.
If you have an address with more than one contiguous string of 0s, where should you place the double colon? RFC 5952 states that the double colon should represent
- The longest string of all-0s hextets.
- If the strings are of equal value, the first string should use the double colon notation.
Combining Rule 1 and Rule 2
You can combine the two rules to reduce an address even further. Table 3 shows examples of this.
Table 3 Examples of Applying Both Rule 1 and Rule 2 (Leading 0s in bold)
Format | IPv6 Address |
Preferred | 0000:0000:0000:0000:0000:0000:0000:0000 |
Leading 0s omitted | 0: 0: 0: 0: 0: 0: 0: 0 |
(::) All-0s segments | :: |
Compressed | :: |
Preferred | 0000:0000:0000:0000:0000:0000:0000:0001 |
Leading 0s omitted | 0: 0: 0: 0: 0: 0: 0: 1 |
(::) All-0s segments | ::1 |
Compressed | ::1 |
Preferred | ff02:0000:0000:0000:0000:0000:0000:0001 |
Leading 0s omitted | ff02: 0: 0: 0: 0: 0: 0: 1 |
(::) All-0s segments | ff02::1 |
Compressed | ff02::1 |
Preferred | fe80:0000:0000:0000:a299:9bff:fe18:50d1 |
Leading 0s omitted | fe80: 0: 0: 0:a299:9bff:fe18:50d1 |
(::) All-0s segments | fe80::a299:9bff:fe18:50d1 |
Compressed | fe80::a299:9bff:fe18:50d1 |
Preferred | 2001:0db8:aaaa:0001:0000:0000:0000:0200 |
Leading 0s omitted | 2001: db8:aaaa: 1: 0: 0: 0: 200 |
(::) All-0s segments | 2001: db8:aaaa: 1:: 200 |
Compressed | 2001:db8:aaaa:1::200 |