IPv4-mapped IPv6 addresses represent IPv4 addresses within the IPv6 address space using the special ::ffff:0:0/96 prefix. The last 32 bits contain the IPv4 address.
Format Structure:
- Prefix: 80 bits of zeros (0000:0000:0000:0000:0000)
- Mapping: 16 bits of ones (ffff)
- IPv4 Address: Last 32 bits (the IPv4 address)
Example: 192.0.2.1 (0xC0.0x00.0x02.0x01)
- Compressed: ::ffff:192.0.2.1 or ::ffff:c000:0201
- Expanded: 0000:0000:0000:0000:0000:ffff:c000:0201
- Binary: 96 zero bits + 16 one bits + 11000000 00000000 00000010 00000001
RFC 4291 Specification:
IPv4-mapped IPv6 addresses are defined in RFC 4291 section 2.5.5.2. They allow IPv6 applications to communicate with IPv4 hosts using IPv6 APIs:
- Format: ::ffff:a.b.c.d where a.b.c.d is the IPv4 address
- Prefix: ::ffff:0:0/96
- Not routable on the Internet (used internally by systems)
Dual-Stack Socket Behavior:
When an application creates an IPv6 socket (AF_INET6) on a dual-stack system:
- It can accept connections from both IPv4 and IPv6 clients
- IPv4 connections appear as IPv4-mapped IPv6 addresses
- Example: IPv4 client 192.0.2.1 appears as ::ffff:192.0.2.1 to the IPv6 socket
- This allows a single socket to handle both protocols
Common Notations:
- ::ffff:192.0.2.1 (dotted-quad notation, most readable)
- ::ffff:c000:0201 (hexadecimal notation)
- 0:0:0:0:0:ffff:192.0.2.1 (uncompressed with dotted-quad)
Important Notes:
- IPv4-mapped addresses are different from IPv4-compatible addresses (::a.b.c.d, now deprecated)
- They are not routable on the IPv6 Internet
- Used for internal system representation only
- Some systems can disable IPv4-mapped address support for security