How to convert IPV4 to IPV6?

 1. What is ipv6?

        IPv6 is the abbreviation of "Internet Protocol Version 6" (Internet Protocol Version 6) in English. It is the next-generation IP protocol designed by the Internet Engineering Task Force ( IETF ) to replace IPv4 . Grains of sand make up an address 

The biggest problem of IPv4 is the lack of network address resources, which seriously restricts the application and development of the Internet. The use of IPv6 can not only solve the problem of the number of network address resources, but also solve the obstacles for various access devices to connect to the Internet 

Second, the composition of IPv6 structure

An IPv6 address is 128 bits long, which is four times the length of an IPv4 address. Therefore, the IPv4 dotted decimal format is no longer applicable, and the hexadecimal representation is used. IPv6 has 3 representations.

First, the hexadecimal notation

The format is X:X:X:X:X:X:X:X, where each X represents 16b in the address, in hexadecimal, for example:

ABCD:EF01:2345:6789:ABCD:EF01:2345:6789

In this notation, the leading zeros of each X can be omitted, for example:

2001:0DB8:0000:0023:0008:0800:200C:417A→ 2001:DB8:0:23:8:800:200C:417A

2. 0-bit compressed representation

In some cases, an IPv6 address may contain a long period of 0 in the middle, and a continuous period of 0 can be compressed into "::". However, in order to ensure the uniqueness of address resolution, "::" in the address can only appear once, for example:

FF01:0:0:0:0:0:0:1101 → FF01::1101

0:0:0:0:0:0:0:1 → ::1

0:0:0:0:0:0:0:0 → ::

3. Embedded IPv4 address representation

In order to realize IPv4-IPv6 interworking, the IPv4 address will be embedded in the IPv6 address. At this time, the address is usually expressed as: X:X:X:X:X:X:dddd, the first 96b is expressed in hexadecimal, and the last 32b The address is represented by IPv4 dotted decimal. For example, ::192.168.0.1 and ::FFFF:192.168.0.1 are two typical examples. Note that in the first 96b, the method of compressing 0 bits is still applicable. 

3. How to convert ipv4 to ipv6 address?

We mentioned above that to communicate with ipv6 addresses, ipv4 addresses need to be converted to ipv6 addresses.

Example:

If an IPv4 address is 172.18.7.12, and there is an existing 32-bit address, how to convert it to ipv6?

1. Non-standard conversion:

It is only necessary to add 0 to 6 groups of 96 bits in front of the IP address, that is,

0000:0000:0000:0000:0000:0000:172.18.7.12

That is ::172.18.7.12 (inline IPv4 notation)

2. Standard conversion

172.18.7.12 is calculated in hexadecimal , namely AC.12.07.22,

However, the AC.12.07.22 string address is still 8 bits, so two sets of v4 addresses are needed to synthesize v6 addresses.

By padding the first 96 bits with zeros, it can be converted to

0000:0000:0000:0000:0000:0000:AC12:0722 or ::AC12:0722.
 

Related: How to convert IPV4 to IPV6?