IPv6 address format and abbreviation
The replacement for IPv4
As we discussed in the previous chapters, during the 1990s we began to quickly run out of IPv4 addresses. To slow down address consumption, engineers developed the RFC 1918 private address ranges and combined them with NAT. These solutions helped extend IPv4’s life, but they didn’t remove the underlying limitation: eventually, the public IPv4 address pool would be exhausted.
Engineers in the 1990s saw this coming and began working on a successor to IPv4: IP version 6 (IPv6). IPv6 was released in the late 1990s, but adoption has been slow, largely because RFC 1918 addressing and NAT have been effective “band-aids” that keep IPv4 usable.
Next, let’s look at how IPv6 addresses are structured.
IPv6 address structure
IPv6 addresses are made up of 8 quartets (also called hextets). An IPv6 address is 128 bits long and is written in hexadecimal. That makes IPv6 addresses 4 times the size of IPv4 addresses. At the time of this writing, you could assign an IPv6 address to each person in the world and still have plenty of addresses left over, which is one reason IPv6 was viewed as a viable successor to IPv4.
Each of the 8 quartets contains 4 hexadecimal digits (for a total of 16 bits per quartet) and quartets are separated by colons.
For example:
0123:4567:89AB:CDEF:1111:2222:AAAA:BBBB
Each digit in a quartet has 4 positional values, which are 8, 4, 2, and 1.
For example, if we were to convert the first quartet from the IPv6 example above, which is 0123, from hexadecimal to binary, we could end up with the following:
Image 235 Image Title - Converting 0123 from Hexadecimal to Binary
As you can see, the Binary value that we would end up with is:
0000 0001 0010 0011
Let’s take a look at another example, using the third quartet, which is 89AB:
Image 236 Image Title - Converting 89AB from Hexadecimal to Binary
The Binary value that we would end up with for this example is:
1000 1001 1010 1011
Each hexadecimal digit has 4 positional values (8, 4, 2, 1). When you count the bits, that gives us 16 bits per quartet (or “hextet”), because there are 4 hexadecimal digits per quartet and 4 bits per digit: .
Each IPv6 address contains 8 quartets in total. So, 8 quartets with 16 bits per quartet gives us 128 bits per IPv6 address: .
An IPv6 address is divided into two portions, similar to IPv4:
- The Network Prefix portion (the network bits)
- The Interface Identifier portion (the host bits)
Image 237 Image Title - Structure of an IPv6 address - Network Prefix and Interface ID
The Network Prefix in IPv6 corresponds to the Network Address portion in IPv4, and the Interface Identifier (Interface ID) corresponds to the Host Address portion in IPv4.
The Network Prefix identifies the IPv6 network the host resides in. The Interface ID is the portion that identifies the host interface (for example, a host NIC or a router interface).
Typically, an IPv6 network prefix is half of the full IPv6 address, which is 64 bits long. As you can see from the image, the portions would be:
- Network portion: 0123:4567:89AB:CDEF
- Host portion: 1111:2222:AAAA:BBBB
When you put them together, you usually represent the IPv6 address using its Prefix length (similar to CIDR notation in IPv4):
0123:4567:89AB:CDEF:1111:2222:AAAA:BBBB/64
The /64 indicates that 64 bits are used for the Network Prefix. You can think of the Prefix length in IPv6 as playing a similar role to a Subnet Mask in IPv4.
Abbreviating IPv6 addresses
IPv6 addresses are long, so typing them can be tedious. In many cases, you can abbreviate an IPv6 address using a few standard rules.
Here are the rules to abbreviating an IPv6 address:
Leading zeroes can be omitted
You can omit any leading zeroes in any quartet. When you do this, it’s assumed the omitted zeroes are still present in that quartet.
For example, consider these two quartets:
0001:DB80
The leading zeroes in the first quartet (0001) can be omitted:
0001:DB80
The final value will look like this:
1:DB80
Another example would be 2001:0DB8. The only zero that can be omitted here is the one before “DB8”:
2001:0DB8 = 2001:DB8
Quartets with all zeroes can be condensed
If you have a quartet that contains all zeroes, you can represent that quartet with just a single zero.
For example:
2001:4567:89AB:CDEF:0000:1111:AAAA:BBBB
This IPv6 address can be condensed to look like this:
2001:4567:89AB:CDEF:0:1111:AAAA:BBBB
Notice how the 5th quartet has been condensed to contain only a single zero. This assumes that the quartet contains all zeroes.
Another way to condense a quartet that contains all zeroes is by replacing it with a double colon (::).
For example:
2001:4567:89AB:CDEF:0000:1111:AAAA:BBBB
The quartet with all zeroes can be abbreviated:
2001:4567:89AB:CDEF:0000:1111:AAAA:BBBB
Then the IPv6 address can be expressed like this:
2001:4567:89AB:CDEF::1111:AAAA:BBBB
Notice that the double colon (::) has replaced the all-zero quartet.
Here’s another example:
2001:0DB8:CAFE:0000:0000:0000:ABCD:1111
Wherever you have a consecutive sequence of all zeroes, you can perform the double colon abbreviation technique:
2001:0DB8:CAFE:0000:0000:0000:ABCD:1111 = 2001:0DB8:CAFE::ABCD:1111
By doing this, we are assuming that between the double colons there are a sequence of all zeroes.