Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I manually transform an IPv4 address into an IPv6 address?

Tags:

ipv6

ipv4

subnet

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.

like image 399
blobs Avatar asked Dec 20 '22 14:12

blobs


1 Answers

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
like image 86
Luke Peterson Avatar answered Apr 29 '23 21:04

Luke Peterson