For Linux, there's a kernel setting for that.<p>Just run<p><pre><code> sysctl -w net.ipv6.bindv6only=1
</code></pre>
so IPv6 will not include IPv4-mapped addresses.<p><a href="https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt" rel="nofollow">https://www.kernel.org/doc/Documentation/networking/ip-sysct...</a>
I think OpenBSD (and other OSes) that do not allow v4 on v6 sockets might be on to something. It was felt convenient for application programmers to only have to listen to one socket for two protocols, but then code after needs to make very sure they know how to handle both families in the correct way for logging and so on, and now much later on it confuses someone that has to dig very deep into why the v4-box talks v4 without using v4.<p>Could be an indication that in the long run, just forcing applications that need both protocols to have separation so you are sure of what they are doing was the correct choice.
You need to be a bit careful with terminology, IPv4-compatible and IPv4-mapped are different, i.e. ::/96 vs. ::ffff:0:0/96.<p>The former (compatible) are not in use anymore, they were specified in an old tunnelling RFC. The latter (mapped) are used for sockets that bind to both IPv4 and IPv6.<p>There are even more ways to include IPv4 addresses in IPv6 ones (NAT64, 6to4, ...)
>I thought I must have this wrong, surely you can’t just smash an ipv4 address in ipv6 field and magic happens?! Nope, didn’t have it wrong, that’s what happens. Linux supports this, and will go on to route the request as IPv4.<p>I mean... it's literally one of the officially defined unicast IPv6 address types. If you ever read the Wikipedia page to learn about what link-local, global unicast, etc. addresses are you surely would have seen it.
In a similar fashion, I once saw a python script that called out to a one-page C program that read a .csv dump (probably from SQLServer) and blew away the upper byte of each character, demoting it to ASCII.<p>Once I understood what was afoot, I was sad that someone had worked so hard when python's open() call supports an 'encoding' argument for just these occasions.
If you think that's wild, just wait until you learn about 6to4 [1] (not to be confused with 6over4 [2] ...)<p>TL;DR: Given a globally unique IPv4 address, you can create automatic tunneling IPv6 networks with the IPv4 address embedded into the IPv6 address space.<p>[1] <a href="https://en.wikipedia.org/wiki/6to4" rel="nofollow">https://en.wikipedia.org/wiki/6to4</a><p>[2] <a href="https://en.wikipedia.org/wiki/6over4" rel="nofollow">https://en.wikipedia.org/wiki/6over4</a>
pretty cool seeing all the stuff people do to make networks talk, honestly makes me wonder - you think stuff like this sticks around because of habit or just taking shortcuts sometimes