Verified: 2026-10-17By Alex Chen (Lead BGP Architect)RFC 4291 & RFC 60529 Min Read

IPv4 to IPv6 Mapping: Dual-Stack Representations Explained

A deep technical breakdown of how IPv4 addresses are mapped into 128-bit IPv6 structures, covering dual-stack socket APIs, NAT64 algorithmic encoding, and transition protocol evolution.

Quick Answer

IPv4-to-IPv6 mapping embeds a 32-bit IPv4 address within a 128-bit IPv6 address structure. The most prevalent standard is the IPv4-mapped IPv6 address (::ffff:a.b.c.d), which allows dual-stack network applications using a single AF_INET6 listening socket to accept both native IPv6 connections and translated IPv4 sessions.

  • IPv4-Mapped format: 80 zeros + 16 ones + 32-bit IPv4 address (e.g., ::ffff:192.0.2.1).
  • NAT64 Well-Known Prefix: 64:ff9b::/96 (RFC 6052) translates between IPv6-only and IPv4-only hosts.
  • IPv4-Compatible (::a.b.c.d) and 6to4 (2002::/16) are formally deprecated due to routing vulnerabilities.

1. The Architecture of IPv4-Mapped IPv6 Addresses

Standardized in RFC 4291 Section 2.5.5.2, an IPv4-mapped IPv6 address consists of 80 bits of zeros, followed by 16 bits of ones (0xFFFF), followed by the 32-bit IPv4 address.

Binary Layout (128 bits):0000...0000 (80 bits) | 1111111111111111 (16 bits) | IPv4 Address (32 bits)
Dotted-Decimal Hybrid:::ffff:192.0.2.128
Full Hexadecimal Representation:0000:0000:0000:0000:0000:ffff:c000:0280
Standard Compressed Hex:::ffff:c000:280

Dual-stack operating systems (Linux, Windows, macOS, BSD) use this structure internally. When a socket is created with socket(AF_INET6, SOCK_STREAM, 0) and the socket option IPV6_V6ONLY is set to 0, the operating system accepts both native IPv6 packets and IPv4 packets. When an IPv4 connection arrives, the kernel passes the remote client IP to the application as ::ffff:x.x.x.x.

2. Transition Mechanisms and Address Encoding Comparison

Over the decades of IPv6 evolution, the IETF standardized several approaches for embedding IPv4 inside IPv6 for routing, tunneling, and translation:

Comparative Analysis of IPv4 Address Embedding Formats in IPv6
MechanismPrefix / NotationRFC StandardStatusPrimary Operating Context
IPv4-Mapped IPv6::ffff:0:0/96 (e.g. ::ffff:192.0.2.1)RFC 4291Active StandardDual-stack socket API abstraction (AF_INET6)
NAT64 Well-Known64:ff9b::/96 (e.g. 64:ff9b::c000:201)RFC 6052Active StandardStateless & stateful algorithmic translation
NAT64 Network-SpecificNSP /96, /64, /56, /48, /40, /32RFC 6052Active StandardEnterprise-specific IPv6-only transition pools
IPv4-Compatible::0:0/96 (e.g. ::192.0.2.1)RFC 4291DeprecatedEarly experimental automatic IPv6-over-IPv4 tunneling
6to4 Anycast Relay2002::/16 (2002:c000:0201::)RFC 3056 / 7526DeprecatedRelay-based tunneling (superseded by native dual-stack)
Teredo Tunneling2001:0000::/32RFC 4380HistoricNAT-traversal UDP encapsulation (obsolete on modern OS)
SIIT (Stateless Translation)Translates headers per RFC 7915RFC 7915Active StandardHigh-throughput data center gateway interworking

IPv4-to-IPv6 Address Classification Decision Tree


                 [ Incoming Address or Transition Mechanism ]
                                      |
                     +----------------+----------------+
                     |                                 |
           [ Host Socket API ]               [ Network Translation ]
                     |                                 |
            Dual-Stack Kernel?                   NAT64 / SIIT?
            ::ffff:a.b.c.d                      64:ff9b::/96
                     |                                 |
       App uses AF_INET6 to accept        IPv6-only host communicates
         both IPv4 & IPv6 clients          with legacy IPv4 Internet
                     |                                 |
                     +----------------+----------------+
                                      |
                         [ Legacy / Deprecated ]
                   ::a.b.c.d (IPv4-compatible, RFC 4291)
                   2002::/16 (6to4, RFC 7526 Deprecated)
                   2001:0000::/32 (Teredo, RFC 4380)

3. Algorithmic Translation with NAT64 and DNS64 (RFC 6052)

In modern mobile cellular networks (such as 4G LTE and 5G NR) and hyperscale cloud environments, user equipment often receives an IPv6-only address. When an app attempts to connect to a legacy server that only publishes an IPv4 A record:

  1. DNS Query: The mobile client issues a AAAA query for legacy.example.com.
  2. DNS64 Synthesis: The DNS64 resolver detects no native IPv6 record, performs an A query to get 198.51.100.42, and prepends the Well-Known Prefix 64:ff9b::/96, returning synthesized record 64:ff9b::c633:642a.
  3. Routing to NAT64 Gateway: The device sends native IPv6 packets to 64:ff9b::c633:642a.
  4. Packet Header Translation: The NAT64 gateway extracts the lower 32 bits, replaces the IPv6 header with an IPv4 header, updates checksums per RFC 7915, and transmits the packet over the IPv4 Internet.

4. Practical Diagnostics: Identifying Mapped Addresses in Code and CLI

Diagnosing whether an incoming client is connected natively or via an IPv4-mapped socket:

Node.js / Express Client IP:req.socket.remoteAddress // Returns "::ffff:203.0.113.15"
Normalized Clean IPv4:ip.replace(/^.*:/, '') // Extracts "203.0.113.15"
Linux Socket Setting Check:sysctl net.ipv6.bindv6only // 0 = dual-stack, 1 = IPv6 only

Frequently Asked Questions

What is the exact difference between an IPv4-mapped and an IPv4-compatible address?

An IPv4-mapped address uses the prefix ::ffff:0:0/96 (e.g., ::ffff:192.0.2.1) and is actively used by dual-stack operating systems to represent IPv4 peers inside IPv6 socket APIs. An IPv4-compatible address uses the prefix ::/96 (e.g., ::192.0.2.1) and was originally intended for dynamic IPv6-over-IPv4 tunneling; it was officially deprecated by RFC 4291 and must not be used in modern networks.

How do I convert a standard IPv4 address to an IPv4-mapped hexadecimal format?

Convert each of the 4 octets into 2-digit hexadecimal numbers. For 192.0.2.1: 192 is C0, 0 is 00, 2 is 02, and 1 is 01. Combine them into two 16-bit groups: C000:0201. Prefix this with 80 zero bits and 16 one bits: ::ffff:c000:0201 or write it in hybrid notation as ::ffff:192.0.2.1.

What is the Well-Known Prefix for NAT64 translation?

RFC 6052 defines 64:ff9b::/96 as the Well-Known Prefix (WKP) for algorithmic translation between IPv6 and IPv4. An IPv6-only client wishing to connect to IPv4 address 198.51.100.1 sends packets to 64:ff9b::198.51.100.1 (or 64:ff9b::c633:6401), which the NAT64 gateway intercepts and translates.

Can an IPv4-mapped IPv6 address be routed over the public IPv6 Internet?

No. IPv4-mapped IPv6 addresses are strictly for internal host API representations (inter-process communication and dual-stack kernel sockets). Border routers will drop any packet containing ::ffff:0:0/96 as a source or destination address because it is non-routable on the global IPv6 backbone.

Data & Technical Sources