IPv6 Address Representation (2024)

When engineers first encounter IPv6, the most obvious and recognizable feature of the protocol is the IP address. It is quite different than the IPv4 one and at first, it seems hard to grasp. The other distinct difference is that IPv6 includes new address types such as link-local addresses. In this lesson, we are going to see that working with IPv6 addresses is not that hard. There are rules to shorten down the address and make it easier to work with.

The IPv6 Address

An IPv6 address is 128 bits in length and is written as eight groups of four hexadecimal digits. Each group is separated from the others by colons (:) as shown in figure 1. Hexadecimal characters are not case sensitive, therefore an address can be written either in uppercase or lowercase, both are equivalent.

IPv6 Address Representation (1)

The eight groups make a total of 32 hexadecimal digits, four bits each, which makes a total of 128 bits. RFC 4291 says that the preferred representation of an IPv6 addressis x:x:x:x:x:x:x:x and RFC 5952 recommends that the address is written in lowercase.

It is obvious that IPv6 addresses are long and hard to remember and work with. That's why there are rulesthatcan significantly shorten the address

Shortening IPv6 addresses

There are two rules, described in RFCs 2373 and 5952, that help engineers to reduce the length of the address representation. It's important to understand from the very beginning that using these two rules shortens only the representation of the address, the address itself is always 128 bits.

Rule 1:Omit groups of all zeros

The first rule that we are going to look at is called Zero Compression. It says that a double colon (::)can replacea single, contiguous string of one or more groups consisting of all 0s. Example 1 illustrates the use of this rule.

IPv6 Address Representation (2)

Note that Groups 4,5,6 and 7 of the IP address are all zeros. The rule says that we can replace them with a single double colon. There is one very important aspect of this rule - this zero compression with a double colon can be applied only once! Because otherwise, the original IPv6 address cannot be recreated from the shorted representation.

IMPORTANT - The::can only appear once in an IPv6 address.

Example 2 illustrates this. Note that there are two contiguous strings of zeros - Group 4 and 5, and Group 7. Having in mind that we can use only one double colon, we can either replace groups 4 and 5 with :: or group 7, but not both.

IPv6 Address Representation (3)

Rule 2: Omit Leading zeros

The other way to shorten addresses is to omit leading zeros in any group of 4 hexadecimal digits. The ruleapplies only to leading zeros and no trailing zeros. Even if a group consists of 4 zeros 0000 we can only omit the leading 3 - 0000. This is illustrated in the following example.

IPv6 Address Representation (4)

Note that all underscored groups have at least on leading zero. For groups 2,3 and 8, the rules are pretty straightforward, you just remove the leading zeros and that's about it. But if you look at group 4 for example, you cannot remove all four zeros, so the trailing zero highlighted in yellow must remain.

Combining Rule 1 and 2

The shortest possible representation is achieved by combining both rules we have discussed. Let's get the IP address from example 3 and apply rule 1 and rule 2 at the same time.

IPv6 Address Representation (5)

You can see that after we applyboth rules, the resulting representation is significantly shorter.

Common Mistakes

There are several common mistakes people make when they start applying these techniques. Let's look at several examples and highlightthe key points.

IPv6 address2001:0cb0:0000:0000:0fc0:0000:0000:0abcCorrectly Shortened2001:cb0::fc0:0:0:abc2001:cb0:0:0:fc0::abcCommon Mistake 1 - using :: twice2001:cb0::fc0::abcCommon Mistake 2 - removing trailing zeros2001:cb::fc:0:0:abc

In this example, in the original address, there are two consecutive strings of zeros, in groups 3 and 4, and in groups 6 and 7. People often try to replace both with :: and end up with two double colons in the shortened address. This is not allowed though, because it creates an ambiguous address representation. The other common mistake is to remove trailing zeros. Note the hex digits in group 2 - 0cb0, people often remove both 0s, but only the leading zero is allowed to be removed.

Let's have a look at a few more examples.

Example 1 - The match-all addressIPv6 address - 0000:0000:0000:0000:0000:0000:0000:0000Shortened - ::

This is one appears very often in questions regarding IPv6 addresses. It is a valid address similar to 0.0.0.0 in IPv4 and its shortened representation is just a double colon.

Example 2 - The loopback addressIPv6 address - 0000:0000:0000:0000:0000:0000:0000:0001Shortened - ::1

The above example is the well-knows v6 loopback address. This is the v6 alternative to the well-known 127.0.0.1 in IPv4.

Example 3 - The all-nodes addressIPv6 address - ff02:0000:0000:0000:0000:0000:0000:0001Shortened - ff02::1

The above example is the well-knows all-nodes multicast address. This is the v6 alternative to the well-known 224.0.0.1 in IPv4.The last example we are going to look at is a random link-local address.

Example 2 - A random link-local addressIPv6 address - fe80:0000:0000:0000:0f19:1faf:008:5010Shortened - fe80::f19:1faf:8:5010

It is very important to understand both rules for shortening addresses and to be able to apply them correctly on any random IPv6 address. There are at least a few questions in the CCNA exam that are related in some way to this topic.

Prefix Length

In IPv4, the network portion of the address is written as a dotted-decimal network mask such as 255.255.255.0 and is called a subnet mask.It can also be represented as classless inter-domain routing (CIDR) notation such as /24 indicating that the first 24 bits of the IP address is the network portion.

InIPv6,there is nodotted-decimal representation but only CIDR notation such as /126. Therefore, there is only one way to write an IPv6 prefix:

ipv6-address/prefix-length

The prefix length is a decimal value showing that the number of leftmost bits of the address is the network portion. Let's take2001:aaaa:bbbb:cccc:0:0:0:10/64 for example. The netmask length of 64 means that the IPv6 subnet is 2001:aaaa:bbbb:cccc::/64 and 2001:aaaa:bbbb:cccc::10 is a node in this subnet.

IPv6 Address Representation (6)

Typically in IPv6, engineers choose prefix lengths that are multiples of four. That makes the prefix easier to understand without using a subnet calculator. Look at the example in figure 6, each additional 4 in the prefix length moves the network portion of the address one hexadecimal digit to the right.

Table 1 - IPv6 Subnetting Example
Prefix LenghtNetwork PortionTotal Addresses
/42::2124
/820::2120
/12200::2116
/162001::2112
/202001:0::2108
/242001:0d::2104
/282001:0df::2100
/322001:0df8::296
/362001:0df8:0::292
/402001:0df8:00::288
/442001:0df8:00f::284
/482001:0df8:00f2::280
/522001:0df8:00f2:0::276
/562001:0df8:00f2:00::272
/602001:0df8:00f2:000::268
/642001:0df8:00f2:0000::264

Summary

  • An IPv6 address is a string of 128 bits represented as 32 hexadecimal digits grouped in eight groups separated by colons.
  • Due to its length, it is hard to work with. Two rules have been introduced that shorten the address representation.
    • Rule 1, called Zero Compression, omits a group of consecutive zeros and replaces them with a double colon (::). This can only be applied once per IPv6 address, otherwise, the shortened representation becomes ambiguous.
    • Rule 2 omits leading zeros in a every group of hexadecimal digits.It does not apply totrailing zeros though.
  • The prefix length of IPv6 address is written inCIDR notation like ipv6-address/prefix-length. There is no dotted-decimal representation such as 255.255.255.0 in IPv6.
  • There are at least a few questions in the CCNA exam that are related in some way to address shortening using the above rules.
IPv6 Address Representation (2024)
Top Articles
Latest Posts
Article information

Author: Patricia Veum II

Last Updated:

Views: 5752

Rating: 4.3 / 5 (64 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Patricia Veum II

Birthday: 1994-12-16

Address: 2064 Little Summit, Goldieton, MS 97651-0862

Phone: +6873952696715

Job: Principal Officer

Hobby: Rafting, Cabaret, Candle making, Jigsaw puzzles, Inline skating, Magic, Graffiti

Introduction: My name is Patricia Veum II, I am a vast, combative, smiling, famous, inexpensive, zealous, sparkling person who loves writing and wants to share my knowledge and understanding with you.