Site map  

IPv6 mapped IPv4 addresses

There are two ways that a dual stack listening socket can be implemented;

  1. Two separate listening sockets: One for IPv4 and one for IPv6.
  2. One combined IPv4 - IPv6 listening socket.

In the latter case the kernel will convert the IPv4 addresses into a special type of IPv6 addresses called 'IPv6 mapped IPv4 addresses'. For this purpose, it appends the IPv4 address to '::ffff:'.
Below a 'visual' description;

Convert each of the four bytes of the IPv4 address into a two-digit hexadecimal number; -> c0.a8.01.08

Merge two bytes to 16 bits;
c0.a8.01.08 -> c0a8.0108

Replace dot by colon;
c0a8.0108 -> c0a8:0108

Remove the leading zeros of each 16-bit number;
c0a8:0108 -> c0a8:108

Prepend prefix '::ffff:';
c0a8:108 -> ::ffff:c0a8:108

Note: This is usually written as ::ffff: The notation used above is a more regular IPv6 notation.


As an illustration, the examples below also include netmasks;

IPv4 addressIPv6 mapped

Note: The IPv6 netmask is the IPv4 netmask plus 96.

Convert IPv4 address to IPv6 mapped IPv4 address

Just in case you ever need to do the conversion yourself, a form that does the conversion for you. If the strings starts with '::ffff:' it will do the conversion the other way around.
You can include netmasks if you like;

Note: The software tries to clean up network/netmask combinations if it thinks they are wrong.
E.G.: Convert '' to '' and '' to ''.
See: Valid IPv4 network addresses and Valid IPv6 network addresses for more info.