You know that feeling you get when you are asked questions on a topic you are not so familiar with? Well, I always got (get) that feeling when it comes to IP version 6 (IPv6). I think it has to do with the human resistance to change, but also because IPv6 seems like a GIANT non-understood dragon. Time to slay the dragon!

Knowledge is the cure for ignorance, so I have decided to invest time in learning about IPv6; after all, that is the direction the world is headed. The best part is that this series will be a documentation of my quest for knowledge and I hope it will also help someone else understand IPv6. In this series, we will be going through the nooks and crannies of IPv6, including the types of addresses, address configuration, neighbor discovery, routing, and so on.

Overview

IPv6 is about more than just the larger address space; it is also about built-in security, ease of configuration, and so on. There are already articles on this site that give an introduction to IPv6, including why we need it and the advantages of IPv6 over IPv4. I will not spend time writing the same things, so you can view the articles here and here. In this series. I want to take a different approach: hands-on learning. I believe what you practice (do with your hands) tends to stick more than what you read over again.

Note: I think the world agrees with me: Experience over “mere” knowledge. Mere not in the sense of insignificant but in the sense of “only.”

IPv6 versus IPv4

For better understanding, it is usually good to go from what we know to what we are trying to learn; in this case, we will briefly look at some of the differences between IPv4 and IPv6:

1. Address length: This is the most obvious difference between IPv6 and IPv4. While IPv4 uses 32 bits for the IP addresses, IPv6 has 128 bits. 2^128 = A lot of IP addresses!
2. Header: The IPv6 header format is different from that of IPv4 and it is also simpler (even though it is twice as large as the IPv4 header because of the 128-bit addresses). There are also other differences, such as the “Options” in the IPv4 header being removed from the IPv6 header and moved to the IPv6 extension headers.

Of course, there are more differences than the ones we have mentioned above, but this list should give you an idea of the significant changes between the two IP versions. You will find an article here that talks more about the differences between IPv4 and IPv6.

I think I should point out now that network communication is in 1s and 0s. In IPv4, we have 32-bit IP addresses represented in dotted decimal, e.g., 192.168.10.1. However, the network devices “think” in binary and this dotted decimal is just to make it more understandable for us humans. So 192.168.10.1 is actually just 11000000 10101000 00001010 00000001 (I put the spaces there for you; the devices don’t).

IPv6 addresses are 128 bits long; 32 bits was hard enough for us to read and now we have 128 bits? Thankfully, we have the text representation for IPv6 addresses called the Colon Hexadecimal notation. It’s simple and we will take an example to see how it works. First you take your 128 bits as shown below (I have split it into two rows for readability):

Then you split those bits into blocks of 16, so you will have 8 blocks of 16 bits:

Now, you represent each 16-bit block as 4 hexadecimal characters (one hexadecimal is 4 bits so 4 hexadecimals will be 16 bits):

Hint: In your head, break each 16-bit block into 4 equal bits and then convert to hexadecimal

Finally, just put colon in between each two 4-hexadecimal blocks.

However, even this colon hexadecimal notation still seems very long, so some smart people came up with shortcut rules for making our lives easier, as detailed in section 2.2 of RFC 4291. These rules are as follows:

1. Leading zeroes in an individual field (a field of 4 hexadecimal characters) can be left out. Trailing zeroes cannot be omitted. Following this shortcut rule, 0DB8 for example can be shortened to DB8. So our address becomes:

2001:DB8:0:0:1:0:0:1

Notice that I have left at least one zero in those fields that had four zeroes. This is because there must be at least one numeral in a field. There is an exception to this rule though as we will see in the next rule.

2. You can indicate one or more groups of 16 bits of zeroes using a double colon, i.e., “::” However, the double colon can only be used once in any single IPv6 address. Using this shortcut rule, our address becomes:

2001:DB8::1:0:0:1 or
2001:DB8:0:0:1::1

The shortcut rules above have shown us how to shorten IPv6 addresses. But how do we (or devices) convert them back to their full form, specifically when we use the double colon? Remember that an IPv6 address is made up of 8 fields so if you have 5 fields including a double colon in a shortened IPv6 address, you just add (8 minus 5) zero fields. For example, to convert 2001:DB8::1:0:1 to full form, we will add 3 zero fields between “DB8” and “1” i.e. 2001:DB8:0:0:0:1:0:1.

The above explanation also gives us insight into why we cannot use the double colon twice in a single IPv6 address. For example, what would be the full form of 2001::DB8::1? Would it be 2001:0:0:0:DB8:0:0:1 or 2001:0:0:DB8:0:0:0:1?

Okay, so almost everyone who has heard of IPv6 has probably encountered these shortcut rules before. However, I told you this series will go far and beyond the common. Apparently, the shortcut rules above have been causing issues for engineers, customers, and so on. This is because of the many forms of representing the same address. For example, all the addresses below are different representations of the same address:

What will happen if you have 2001:DB8:0:0:0:1:: stored in a spreadsheet, but you search for 2001:DB8::1:0:0? It will not be found because even though they are the same address, the search string is different. Also, note that “db8” and “DB8” mean the same thing in IPv6 because the addresses are case-insensitive. However, operating systems like UNIX are case-sensitive; therefore, using regex expressions in systems like these may be very frustrating.

So another set of smart guys wrote an RFC to update (not make obsolete) RFC 4291. This is RFC 5952, published in August 2010 by Kawamura and Kawashima. Note that this RFC provides only a recommendation and all implementations must be able to handle the RFC 4291 format. Here are the recommendations:

1. Leading zeroes MUST be suppressed. It means 2001:0db8::1:0:01 is not acceptable. The acceptable representation is 2001:db8::1:0:1. Also, a single field of 0000 must be represented by a single 0.
2. You MUST use the “::” to its maximum capacity. This means that 2001:db8::0:1:0:1 is not acceptable because the next zero field after the double colon could have also been included in the double colon. This address should be represented as 2001:db8::1:0:1.
3. The “::” MUST NOT be used to represent just one 16-bit 0 field. Remember that the shortcut rule above says “one or more groups of 16 bits of zeroes” can be indicated with the double colon. This RFC, however, recommends using the double colon for “two or more groups of 16 bits of zeroes.” So 2001:db8:0:1:1:1:1:1 should not be represented as 2001:db8::1:1:1:1:1.
4. If you have multiple groups of 16-bit zeroes that can be replaced by “::”, you MUST use the “::” in place of the longest group. For example, 2001:db8:0:0:0:1:0:0 must be written as 2001:db8::1:0:0 instead of 2001:db8:0:0:0:1::

Also, if you have multiple groups of 16-bit zeroes that are of equal length, then you MUST use “::” in place of the first group. For example, 2001:db8:0:0:1:0:0:1 is shortened as 2001:db8::1:0:0:1 instead of 2001:db8:0:0:1::1.

5. Finally, you MUST use all lowercase. Of course, this only applies to the hexadecimal characters “a” through “f”.

There are other recommendations that talk about special addresses and combining IPv6 addresses with port numbers, but we will not discuss those here.

Summary

Let’s end this introductory article here for now. In this article, we have discussed some of the differences between IPv4 and IPv6. We also mentioned that IPv6 is not only about the larger address space but other features, such as built-in security. We went on to look at the IPv6 addressing syntax and its shortcut rules and also pointed out newer recommendations to resolves problems faced with the shortcut rules.

In the next article, we will dive into the types of IPv6 addresses, which I used to find difficult to understand (or commit to memory). I hope I have wetted your appetite for this IPv6 series. Knowledge is exciting.