7

I'm reading about how to configure IPv6 on Ubuntu, I've gotten to the section about Reading IPv6 Addresses and though the first two examples make sense to me, the last one escapes my grasp a bit, as it's been a few years since my last networking class:

How does one convert the third form into the long form?

Here is the example I am having trouble with:

  • third form:         - 2002::10:0.0.1
  • long form:         - 2002:0000:0000:0000:0000:0000:0a00:0001
  • canonicalform: - 2002::a00:1

I understand hex so far as instead of ending up with the number ten when you count beyond nine you end up with A, B, C, D, E, and F before incrementing the digit in the next column.

Can you please show me how this works using math, not just some online JavaScript converter?

Thank you!

leeand00
  • 4,807
  • 13
  • 64
  • 106

2 Answers2

6

In IPv4, each byte is represented by a number, 0 through 255; in IPv6, the hex representation is used instead, 00 through ff. The conversion that's done there is to map the four bytes of the IPv4 address to the last 4 bytes of the IPv6 address:

IPv4:

aaa.bbb.ccc.ddd

IPv6:

XXXX::AABB:CCDD

So, with an input of 10.0.0.1, the bytes are 0a, 00, 00, 01; leading to:

::0a00:0001

(which shortens to ::a00:1)

For another example, let's take 192.168.50.254:

::c0a8:32fe
Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • Okay so in ipv6 you have a hexquad, and in ipv4 you have a octet... a hexquad represents 16 bits... an octet represents 4 bits? – leeand00 Oct 06 '11 at 19:19
  • 2
    Right, except 8 bits per IPv4 octet. IPv4 has 4 octets of 8 for a total of 32 bits, while IPv6 has 8 colon-separated groups of 16 bits for a total of 128 bits. – Shane Madden Oct 06 '11 at 19:21
  • Okay I think I understand this now, here's a rather verbose explanation of the conversion: http://leeand00.tiddlyspot.com/#[[Converting%20IPv4%20addresses%20to%20IPv6%20Equivalent]] – leeand00 Oct 06 '11 at 20:24
3

You can look at the conversion to different formats using v6decode; try hovering over the different parts of the address to see how they relate between the different formats.

Beau
  • 287
  • 2
  • 11