Put another way, if an address is IPv4, why bother to express it as IPv6 at all?
In "automatic" tunneling, hybrid IPv4/IPv6 addresses are created by extending 32-bit IPv4 addresses to 128 bits by adding leading zeros. IPv6 packets are encapsulated within IPv4 headers, so that one address can be converted to the other automatically at the tunnel endpoints.
The IPv6 addressing architecture allows you use the two-colon (::) notation to represent contiguous 16-bit fields of zeros. For example, you might abbreviate the IPv6 address in Figure 3–2 by replacing the two contiguous fields of zeros in the interface ID with two colons.
IPv6 increases the IP address size from 32 bits to 128 bits, thereby supporting more levels of addressing hierarchy, a much greater number of addressable nodes, and simpler autoconfiguration of addresses.
In November 2020, OMB issued memorandum M-21-07, "Completing the Transition to Internet Protocol Version 6 (IPv6)," which outlines the Federal government's strategic intent "to deliver its information services, operate its networks, and access the services of others using only IPv6."
It’s IPv4 expressed through IPv6 so that the application only needs to support one IP stack.
Being able to reference IPv4 addresses through IPv6 notation means I can work on getting IPv6 support really solid in my application, and not have to worry about duplicating effort.
These days some distributions disable IPv4 compatibility by default (e.g. Debian), and also Windows does this by default. To accommodate this as a programmer you should bind two sockets: one IPv4 socket, and one IPv6 socket with the IPV6_V6ONLY
flag (which forces it to bind IPv6–only with no IPv4 compatibility, no matter the state of /proc/sys/net/ipv6/bindv6only
).
In the comments below, Mike linked me to this great site with info on how you should use sockaddr_storage for AF_–independent programming (which has great relevance whether you decide to go AF_INET6, or decide to use AF_INET and AF_INET6 side by side). Also I like Beej's Guide to Network Programming, which has some similar information too. Recommended reading. Thanks, Mike!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With