IPv4-Mapped IPv6 Address Cheat Sheet

Sometimes networking is cool, sometimes it’s just weird. Linux loves to use IPv4-mapped IPv6 addresses when passing information to servers, so here’s a quick cheat sheet on working them out…

IPv4IPv6 Mapped
127.0.0.1::1 technically or ::ffff:127.0.0.1
10.0.0.1::ffff:10.0.0.1/128 (or just ::ffff:10.0.0.1)
10.0.0.0/24::ffff:10.0.0.0/120
10.0.0.0/16::ffff:10.0.0.0/112 (16 + 96 = 112)
10.0.0.1/32::ffff:10.0.0.1/128 (32 + 96 = 128)

You can write the IPv4 part in hex too if you want to be extra annoying: ::ffff:a00:0/120 (since 10.0.0.0 = 0x0a000000).

The /120 is calculated by adding 96 to your IPv4 prefix length.

The formula: IPv6 prefix = IPv4 prefix + 96

Why 96? The ::ffff: prefix takes up 96 bits (the first 96 bits are fixed).

References



#networking #linux #IPv4 #IPv6