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.


Forum Replies

  1. Hello Sir…
    i want to know that string of zero’s can be removed by :: and a group of 4 zero’s can be removed by :0 but my question is that these two can be done in together or one can be removed at a time ?? i.e we can either remove string of zero or group of 4 zero’s at a time? or together?

  2. Hello Anshul

    If you have the following address:

    2041:0000:140F:1234:1234:6543:875B:131B

    you can shorten it to:

    2041:0:140F:1234:1234:6543:875B:131B

    but you can’t shorten it to:

    2041::140F:1234:1234:6543:875B:131B

    A string of at least two sets of zeros such as :0000:0000: can be replaced with :: but a single string of zeros such as :0000: can only be replaced with :0:

    Now having said that, even if you do it people will still know what you’re talking about, and some operating systems or network device firmware may even accept it, but according to the official rul

    ... Continue reading in our forum

  3. Q-1-Why Trailing 0 Cant be removed , need an example plz …!!

    Q-2 :- Why they decided to be ipv6 in Hexadecimal, could not have been possible in decimal ??

  4. Hello Narad

    For each hextet, you must either remove leading zeros or trailing zeros. If you remove both, then you will not have a unique address. For example, let’s sa you have the following:

    2041:0010:140F::875B:131B

    In that second hextet, we have 0010. If you remove both the leading and trailing zeros, you get this:

    2041:1:140F::875B:131B

    But how is a network device to know what that single “1” means?

    ... Continue reading in our forum

Ask a question or join the discussion by visiting our Community Forum