How the conversion works
An IPv4 address is 32 bits, written as four decimal numbers. An IPv6 address is 128 bits, written as eight groups of four hex digits. To fit IPv4 into IPv6, each pair of IPv4 numbers becomes one hex group, and a fixed prefix fills the rest.
| Step | Example: 192.0.2.1 |
|---|---|
| Split into four numbers | 192 · 0 · 2 · 1 |
| Each number to two hex digits | c0 · 00 · 02 · 01 |
| Pair them into two groups | c000 : 0201 |
| Add the IPv4-mapped prefix | ::ffff:c000:201 (or ::ffff:192.0.2.1) |
Which IPv6 form to use
- IPv4-mapped (
::ffff:0:0/96): the one you will meet most, in server logs, socket APIs and databases that store every address as IPv6. - NAT64 (
64:ff9b::/96): for IPv6-only networks reaching IPv4 servers. - 6to4 (
2002::/16): an old tunnelling method, deprecated in 2015 (RFC 7526). You may still see it in old configurations. - IPv4-compatible (
::a.b.c.d): deprecated since 2006. Do not use it.
Private addresses such as 192.168.1.1 convert the same way, but they stay private: the IPv6 form does not make them reachable from the internet. To see who owns a public address, use the IP WHOIS lookup.