Friday, February 21, 2020

Shortening IPv6 Addresses

IPv6 addresses are hexadecimal and since they are 128-bit, they are quite long. Imagine you have to call a friend and ask him/her to ping the following address:
2041:0000:140F:0000:0000:0000:875B:131B
To make our lives a bit better, IPv6 addresses can be shortened.  Let’s take a look at some examples and I’ll show you how it works:
  • Original: 2041:0000:140F:0000:0000:0000:875B:131B
  • Short: 2041:0000:140F::875B:131B
If there is a string of zeros then you can remove them once. In the example above I removed the entire 0000:0000:0000 part. You can only do this once, your IPv6 device will fill up the remaining space with zeros until it has a 128 bit address.
There is more however, the address can be shortened even more:
  • Short: 2041:0000:140F::875B:131B
  • Shorter: 2041:0:140F::875B:131B
If you have a “hextet” with 4 zeros then you can remove those and leave a single zero. Your IPv6 device will add the remaining 3 zeros.
When we talk about IPv4 addresses, we use the term “octet” to define a “block” of 8 bits. In IPv6, there is no official term (yet) and there is an IETF draft that discusses the names to be used. The official term for 4 hexadecimal values is “hexadectet”, this is hard to remember/pronounce so the short form “hextet” will be used.
Leading zeros can also be removed, here’s another address to demonstrate this:
  • Original: 2001:0001:0002:0003:0004:0005:0006:0007
  • Short: 2001:1:2:3:4:5:6:7
By removing these zeros we get a nice short IPv6 address.
To summarize these rules:
  • An entire string of zeros can be removed, you can only do this once.
  • 4 zeros can be removed, leaving only a single zero.
  • Leading zeros can be removed.
I hope this helps! Feel free to share this post or leave a comment in our forum if you have any questions.

No comments:

Post a Comment