An IPv4 address does not have a single IPv6 equivalent. It has a few, each built for a different job. The one most people mean is the IPv4-mapped address, written ::ffff:a.b.c.d, which carries the 32-bit IPv4 address inside an IPv6 address so a dual-stack system can reach IPv4 hosts. The IPv4 to IPv6 converter shows that form along with the compatible and 6to4 forms for any address you enter.
Here is what each form is and how it is built.
The IPv4-mapped form
IPv4-mapped addresses live in the ::ffff:0:0/96 block. The first 80 bits are zero, the next 16 bits are ffff, and the last 32 bits hold the IPv4 address. The result is usually written with the IPv4 part still in dotted-decimal, because that reads more clearly:
192.0.2.5 → ::ffff:192.0.2.5
In pure hexadecimal the same address is ::ffff:c000:205, because 192.0.2.5 is c000:0205 in hex. Both spellings mean the same 128-bit value.
This is the representation you see most often in practice. When a server binds an IPv6 socket on a dual-stack machine, incoming IPv4 connections show up with the client address in this mapped form. That is why an IPv4 address often appears in logs with an ::ffff: in front of it.
Turning octets into hex
To build any of these forms by hand, you convert each pair of IPv4 octets into one 16-bit hex group. Take 192.0.2.5:
- 192 in hex is
c0, and 0 is00, so the first group isc000. - 2 in hex is
02, and 5 is05, so the second group is0205.
So 192.0.2.5 is c000:0205. Those two groups are what get slotted into the IPv6 forms below.
The IPv4-compatible form
The IPv4-compatible address uses the ::/96 prefix: 96 zero bits followed by the 32-bit IPv4 address. For our example that is ::192.0.2.5, or ::c000:205 in hex.
This form is deprecated. It was an early idea for carrying IPv4 over IPv6 and is no longer used in new deployments, but the converter still shows it so you can recognise it if it turns up in old configuration or documentation. The mapped form replaced it for everyday dual-stack use.
The 6to4 form
6to4 is a tunneling scheme that gives an IPv4 host an entire IPv6 /48 to use. It embeds the IPv4 address into the 2002::/16 prefix:
192.0.2.5 → 2002:c000:205::/48
The two groups after 2002 are the IPv4 address in hex, c000:205. Because every 6to4 address derives from one IPv4 address, you can read the original IPv4 straight back out of it, which is what the IPv6 to IPv4 converter does in reverse.
Full versus compressed
Each of these forms can be written in full or compressed. The mapped address ::ffff:192.0.2.5 is already compressed; in full it is 0000:0000:0000:0000:0000:ffff:c000:0205. The converter shows both, since some older tools want the full eight-group spelling. If you only have the short form and need the long one, the rules are the same as for any IPv6 address; see how to expand an IPv6 address. To go the other way and tidy a long address up, see how to compress an IPv6 address.
When you actually need this
Most of the time you do not convert IPv4 to IPv6 by choice; you run into one of these forms and need to make sense of it. A mapped address in a log tells you which IPv4 client connected. A 6to4 prefix in a routing table tells you which IPv4 gateway it belongs to. Knowing which prefix means what saves you from guessing.
When you do need to produce one of these forms, enter the IPv4 address into the IPv4 to IPv6 converter. It returns the mapped, compatible and 6to4 forms together, each in compressed and full notation, so you can copy whichever one the system in front of you expects.