How do I manually transform an IPv4 address into an IPv6 address?
Asked Answered
S

2

5

I would like to know if there is any manual method in transforming an IPv4 address to an IPv6 address without the use of an conversion calculator or tool. For example:

I have an IPv4 address and it is given as:

129.130.100.11

and when it is transformed the answer is given as:

0::FFFF:8182:640B

Are there any formula used to perform such transformation?

Any help would be nice.

Senseless answered 15/6, 2014 at 6:48 Comment(0)
D
9

For IPv6, the octets are usually represented as hexadecimal numbers, whereas IPv4 uses decimal. So, an extremely simplified method is to first convert each of the decimal octets (8 bits) to hexadecimal:

129 becomes 81
130 becomes 82
100 becomes 64
11 becomes 0B

Then concatenate the results with a colon between the first two and the last two octets:

8182:640B

And add ::FFFF: to the front of the string:

::FFFF:8182:640B

There are however a few different formats for an IPv6 address. I left these out above as you can see they all include some type of decimal-hexadecimal conversion and some simple string formatting. Other alternatives include:

  • 6 to 4 address:
    • 2002:8182:640B:0:0:0:0:0
    • 2002:8182:640B::
  • IPv4-mapped address:
    • 0:0:0:0:0:FFFF:129.130.100.11
    • ::FFFF:129.130.100.11
    • ::FFFF:8182:640B
  • IPv4-compatibility address:
    • 0:0:0:0:0:0:129.130.100.11
    • ::129.130.100.11
    • ::8182:640B
Delusion answered 15/6, 2014 at 6:56 Comment(1)
IPv4-Compatible IPv6 addresses are deprecated since 2006 (RFC 4291). You can savely ignore them.Clifton
E
3

While the other answer is correct as well, a valid IPv6 address may end with decimal rts as well, exactly in order to provide this sort of things.

You can just write

::FFFF:129.130.100.11

and you are done.

Edlin answered 15/6, 2014 at 7:59 Comment(1)
Thanks, left it out for brevity, but have updated my answer to include the other possible formats.Delusion

© 2022 - 2024 — McMap. All rights reserved.