RFC 4291 (which obsoletes RFC 3513 and RFC 2373) specifies the IPv6 addressing architecture. IPv6 addresses are 128 bits in length. For display, the IPv6 addresses have eight 16-bit groups. Each 16-bit group is represented using hexadecimal numbers. (See Appendix B, “OSI Model, TCP/IP Architecture, and Numeric Conversion,” for a quick review on hexadecimal numbers.) The hexadecimal value is x:x:x:x:x:x:x:x, where each x represents four hexadecimal digits (16 bits).
An example of a full IPv6 address is 1111111000011010 0100001010111001 0000000000011011 0000000000000000 0000000000000000 0001001011010000 0000000001011011 0000011010110000.
The hexadecimal representation of the preceding IPv6 binary number is
FE1A:42B9:001B:0000:0000:12D0:005B:06B0
Groups with a value of 0000 can be represented with a single 0. For example, you can also represent the preceding number as
FE1A:42B9:01B:0:0:12D0:05B:06B0
You can represent multiple groups of 16-bit 0s with ::, which is allowed to appear only once in the number. Also, you do not need to represent leading 0s in a 16-bit group. Furthermore, RFC 5952 states that “leading zeros MUST be suppressed.” Therefore, the preceding IPv6 address can be further shortened to
FE1A:42B9:1B::12D0:5B:6B0
Tip
Remember that the fully expanded address has eight blocks and that the double colon represents only 0s. You can use the double colon only once in an IPv6 address.
RFC 5952 also states that when you have two options to suppress zeros, the longest run of 16-bit 0 fields must be shortened. If both options have the same length, then the first sequence of zero bits must be shortened. For example:
2001:4C:0000:0000:9EA:0000:0000:1
is shortened to
2001:4C::9EA:0:0:1, and not to 2001:4C:0:0:9EA::1
To expand a compressed address, the process described earlier is reversed: Add leading 0s in groups where they have been omitted, and then add 0s represented by ::. For example, the IPv6 address 2001:4C::50:0:0:741 expands as follows:
2001:004C::0050:0000:0000:0741
Because there should be eight blocks of addresses and you have six in this address, you can expand the double colon to two blocks as follows:
2001:004C:0000:0000:0050:0000:0000:0741
IPv4-Mapped IPv6 Addresses
As described in RFCs 4921 and 4038, IPv6 allows for IPv4-mapped IPv6 addresses. In a mixed IPv6/IPv4 environment, the IPv4 portion of the address requires the last two 16-bit blocks, or 32 bits of the address, which is represented in IPv4 dotted-decimal notation. The portion of the IPv6 address preceding the IPv4 information is 80 0s and then 16 1s. Six hexadecimal 16-bit blocks are concatenated with the dotted-decimal format. This form is 0:0:0:0:0:FFFF:d.d.d.d, where each block represents the hexadecimal digits, and d.d.d.d is the dotted-decimal representation.
An example of a mixed full address is 0000:0000:0000:0000:0000:FFFF:100.1.1.1; this example can be shortened to 0:0:0:0:0:FFFF:100.1.1.1 or ::FFFF:100.1.1.1.