# Shortening IPv6 Addresses

This topic is to discuss the following lesson:

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?

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 rules, this is what needs to be done.

I hope this has been helpful!

Laz

1 Like

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 ??

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? How many trailing and/or leading zeros were removed? It could be 1000, 0100, 0010, or 0001, there is no way to tell.

So, you must either remove leading zeros, OR trailing zeros not both. So by convention, they decided to remove only the leading zeros.

I don’t know the official reasoning behind the choice, but I can tell you why I think they decided to use hex. When dealing with IPv6 addresses, it is most useful to use binary. It’s easier to deal with prefixes, subnets, and so on. That’s how network devices see these addresses too, however, writing out 128 bits in binary becomes difficult to read for humans. An alternative had to be found.

Using hexadecimal becomes easier than decimal because it is base 16. This means that each hex digit corresponds to four bits exactly. Decimal digits however don’t correspond exactly to a certain number of bits. This makes subnetting and other calculations much easier with hex because you can subnet on the boundaries between the hex digits, and know what that prefix will be. With decimal, it’s not possible. Remember IPv4 subnetting? When you use dotted decimal format, it can become difficult to subnet.

I hope this has been helpful!

Laz