How to find IPv6 Prefix

if you have a calculation for say /98 an example i use is 1234:0010:abcd:4563:2829:5546:5663:3665,
how does the calculation come to be “1234:0010:abcd:4563:2829:5546:4000::” and not “1234:0010:abcd:4563:2829:5546:5600::” if we are converting half nibble to 0’s does that mean that the 5663 bit in binary stands for “0101 0110 0110 0011” is because the 0110 0011 tend to 0’s the first 0110 is affected as well? if yes please explain the logic behind it. I’m unable to understand why it’s 4000s instead of 5600::/98. Thanks in advance.

Hello Vivek

Going through the calculation, the /98 tells us that we must use the first 98 bits as the prefix. This means that these should remain unchanged. Take a look at your initial IPv6 address, and taking into account that these are hex digits, which means that each digit represents four bits, (a nibble), we can conclude that:

1234:0010:abcd:4563:2829:5546:5663:3665

the first 96 (yes 96) bits are contained within the following portion of the address:

1234:0010:abcd:4563:2829:5546:5663:3665

The next two bits, which complete the 98 bit prefix we’re looking for are contained within the very next digit, which is 5 (in hex). In binary, this is 0101. The prefix splits this nibble in two, so the first two bits should remain unchanged, while the next two should become zeros. This results in a value of 0100 for the nibble, which is 4.

So the prefix of 1234:0010:abcd:4563:2829:5546:5663:3665/98 is indeed:

1234:0010:abcd:4563:2829:4000::/98

So yes, you are correct in your calculations.

I hope this has been helpful!

Laz

Hi Lazaros, Thanks for the clear explanation, I think I assumed the 5663 bit, as 5th bit as 97 and 6 as 98, and looked at the one after that as 0’s, but in reality binary portion of 5663 is zero’s, in which “0101011001100011” is 0100 is 4000::/98 now that makes sense, I was probably speeding calculating to overlook this, but really thankful to be part of NL and have wonderful N/w guys around.

Hello Vivek

Great to hear that it’s been of help. We’re happy to have you with us and looking forward to helping you to further your certification and professional goals in networking!!

Laz

Very easy to understand and straight to the point like always.

1 Like