InetAddress.getLocalHost() returns APIPA/link-local address in a Windows 2008 SP2 or later version Windows OS with multiple-NICs.
Alan.Bateman at oracle.com
Mon Nov 28 01:41:16 PST 2011
On 28/11/2011 06:52, Charles Lee wrote:
> Hi guys,
> When we call InetAddress.getLocalHost(), we usually return the first
> entry of inet address array. The array keeps the same order as
> getaddrinfo gets (duplication has been removed).
> In Windows 2008 sp2 or later version Windows OS with multiple NICs,
> getaddrinfo() sorts the Addresses and linklocal/APIPA address appears
> first now. So user will get a APIPA address even if a more useful
> address is available.
I'm curious about this behavior. Are you saying that the host's name
resolves to addresses on all interfaces? Also I thought that the default
was to sort the addresses so that IPv4 addresses appear before IPv6
addresses (unless java.net.preferIPv6Addresses is set to true).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the net-dev