InetAddress.get*() vs RFC 6724
Alan Bateman
alan.bateman at oracle.com
Fri Feb 6 10:45:43 UTC 2026
On 06/02/2026 10:08, Robert Stupp wrote:
> Hi all,
>
> I wanted to test for the appetite to change the current default
> behavior of the IP address lookup policy on dual-stack (IPv4+IPv6)
> systems.
>
> The default evaluated in InetAddress.initializePlatformLookupPolicy()
> yields 'IPV4_FIRST' to return IPv4 addresses before IPv6 addresses
> unless 'java.net.preferIPv6Addresses' is set to 'true'. I wonder
> whether this could be changed to the system default, relying on what
> 'getaddrinfo' returns?
>
> This would make Java compliant with RFC 6724, which (strongly)
> recommends to yield IPv6 addresses first.
>
> Naively speaking, it can be confusing if something like 'curl' or
> 'wget' connect via IPv6, but any Java application connects via IPv4.
>
> Although it's a tiny code change, it would be a "big" or "surprising"
> behavior change. Therefore I think, if there's appetite for such a
> change, it would need to go into one of the next major releases.
>
> WDYT?
>
Moving to net-dev as that is where the networking APIs are maintained.
As an initial comment, changing the JDK to prefer IPv6 addresses by
default would be a significant and observable change. TBH, I don't see
this being changed without a wide survey of configurations and a JEP
that lays out the case and implications of the change.
Is your motive for asking solely because curl/wget tools prefer IPv6?
I'm wondering if there is more to the question, maybe HTTP protocol
handler or client only using the first address?
-Alan
More information about the net-dev
mailing list