IPv4 ↔ IPv6 Converter
Free ToolResults
Why IPv4-to-IPv6 Conversion Exists
IPv4 uses 32-bit addresses, giving a theoretical maximum of 4,294,967,296 unique addresses — a pool that was effectively exhausted by 2011 as IANA allocated the last large blocks to regional registries. IPv6 was designed to succeed it, using 128-bit addresses to provide approximately 3.4 × 10³⁸ unique values — enough to assign billions of addresses to every grain of sand on Earth.
Because the global transition from IPv4 to IPv6 spans decades, both protocol versions must coexist. This creates a practical need to represent IPv4 addresses within the IPv6 namespace so that dual-stack systems, tunneling protocols, and compatibility layers can operate correctly. Two standardised mechanisms cover the most common scenarios:
- IPv4-Mapped IPv6 Addresses — a local representation used inside a host's networking stack (RFC 4291). Not routed across the internet.
- 6to4 Addresses — a routing mechanism that embeds a public IPv4 address into an IPv6 prefix, enabling IPv6 traffic to tunnel through an IPv4 backbone (RFC 3056).
IPv4-Mapped IPv6 Addresses (::ffff:x.x.x.x)
An IPv4-mapped IPv6 address represents an IPv4 address within the IPv6 address space for use by applications and the operating system. It is defined in RFC 4291 and appears on the wire only within a single host — it is never transmitted as-is across the public internet.
The 128-bit structure is divided into three fixed regions:
When compressed using standard IPv6 shorthand, the eighty leading zero-bits collapse to ::, and the result takes the form ::ffff:w.x.y.z (mixed dotted-decimal) or ::ffff:WXYZ:ABCD (all-hex groups). Both forms are equivalent representations of the same 128-bit value.
The primary use case is dual-stack server sockets. When an IPv6 socket on a Linux or Windows host receives a connection from an IPv4 client, the OS presents the source address to the application in IPv4-mapped form — for example, ::ffff:203.0.113.1. The application can then work with a single address family regardless of which IP version the client used.
6to4 Transition Addresses (2002::/16)
6to4 (RFC 3056) is a mechanism that allows IPv6 networks to communicate across an IPv4 backbone by automatically tunnelling IPv6 packets inside IPv4 headers. Unlike IPv4-mapped addresses, 6to4 addresses are real routable IPv6 prefixes that can appear on the public internet.
Every public IPv4 address automatically maps to a unique /48 block within the 2002::/16 range. The 48-bit site prefix is constructed as:
- Bits 1–16: Fixed prefix
2002— IANA-assigned identifier for all 6to4 space - Bits 17–32: First two octets of the IPv4 address in hexadecimal
- Bits 33–48: Last two octets of the IPv4 address in hexadecimal
- Bits 49–128: Subnet and interface identifier assigned by the site operator
A 6to4 router reads the embedded IPv4 address from the destination prefix and uses it as the outer IPv4 destination, encapsulating the IPv6 packet for delivery. Note: 6to4 was deprecated in RFC 7526 due to reliability problems with anycast relay routers, but it remains important for networking examinations and legacy network analysis.
Step-by-Step: IPv4 to IPv6 Conversion
The core operation is identical for both output formats — only the prefix changes. Using 192.168.1.100 as an example:
Convert each decimal octet to 2-digit hexadecimal.
192 ÷ 16 = 12 rem 0 → c0 |
168 ÷ 16 = 10 rem 8 → a8 |
1 ÷ 16 = 0 rem 1 → 01 |
100 ÷ 16 = 6 rem 4 → 64
Pair adjacent octets to form two 16-bit hex groups.
Octets 1 + 2: c0 + a8 = c0a8 |
Octets 3 + 4: 01 + 64 = 0164
IPv4-Mapped — prepend ::ffff: to the two groups.
Result: ::ffff:c0a8:0164
Full expanded form: 0000:0000:0000:0000:0000:ffff:c0a8:0164
6to4 — prepend 2002: and append ::/48.
Result: 2002:c0a8:0164::/48
Step-by-Step: IPv6 to IPv4 Extraction
Reverse conversion is only possible for addresses that embed an IPv4 value — IPv4-mapped and 6to4 types. Using ::ffff:4a7d:4e01 as an example:
Expand compressed notation by replacing :: with the missing zero groups.
::ffff:4a7d:4e01 has 3 explicit groups after ::, so 5 zero groups fill the gap:
0000:0000:0000:0000:0000:ffff:4a7d:4e01
Identify the address type from the prefix.
Groups 1–5 are all 0000 and group 6 is ffff → this is an IPv4-mapped address. The IPv4 data lives in groups 7 and 8.
If group 1 were 2002, it would be 6to4 and the IPv4 data would be in groups 2 and 3.
Extract and split the IPv4-bearing groups into individual bytes.
Group 7 4a7d → bytes 4a and 7d
Group 8 4e01 → bytes 4e and 01
Convert each 2-digit hex byte to decimal.
4a = (4 × 16) + 10 = 74 |
7d = (7 × 16) + 13 = 125 |
4e = (4 × 16) + 14 = 78 |
01 = 1
Result: 74.125.78.1
How to Verify a Conversion
Four independent methods can confirm a conversion is correct — using more than one gives high confidence:
- Round-trip check — convert the result back using the opposite method. If the output matches the original input exactly, both conversions are consistent. For example:
8.8.8.8→::ffff:0808:0808→8.8.8.8✓ - Manual byte spot-check — pick any octet, convert it to hex by hand (divide by 16, record quotient and remainder as hex digits), and compare to the corresponding byte in the result. For octet 172: 172 ÷ 16 = 10 rem 12 →
ac. Confirm this appears in position 1 of the output hex groups. - Group count check — fully expand the IPv6 result and count the groups separated by colons. A valid IPv6 address always has exactly 8 groups of 4 hex digits. Any deviation indicates a formatting or length error.
- Octet range check — every decimal octet extracted from an IPv6 address must fall in the range 0–255. A value outside this range means a hex-to-decimal arithmetic error occurred.
Worked Examples
Six complete conversions with hex arithmetic shown at each step. The first five convert IPv4 to both IPv6 formats; the sixth demonstrates reverse extraction.
| IPv4 Address | Hex conversion | IPv4-Mapped IPv6 | 6to4 Prefix |
|---|---|---|---|
| 192.168.1.1 | c0 a8 01 01 → groups c0a8:0101 |
::ffff:c0a8:0101 |
2002:c0a8:0101::/48 |
| 10.0.0.1 | 0a 00 00 01 → groups 0a00:0001 |
::ffff:0a00:0001 |
2002:0a00:0001::/48 |
| 8.8.8.8 | 08 08 08 08 → groups 0808:0808 |
::ffff:0808:0808 |
2002:0808:0808::/48 |
| 172.16.5.20 | ac 10 05 14 → groups ac10:0514 |
::ffff:ac10:0514 |
2002:ac10:0514::/48 |
| 203.0.113.45 | cb 00 71 2d → groups cb00:712d |
::ffff:cb00:712d |
2002:cb00:712d::/48 |
| Reverse extraction example — IPv6 → IPv4 | |||
::ffff:0808:0808 |
Groups 7–8: 0808 + 0808 → bytes 08 08 08 08 |
Extracted IPv4: 8.8.8.8 ✓ (round-trip verified with row 3) | |
Hex reminder for the examples: 10=0a, 16=10, 20=14, 45=2d, 113=71, 172=ac, 203=cb. Each value is derived by dividing by 16: for 172, 172 ÷ 16 = 10 remainder 12, giving digits a (10) and c (12), hence ac.