InetAddress.getLocalHost() returns APIPA/link-local address in a Windows 2008 SP2 or later version Windows OS with multiple-NICs.
Charles Lee
littlee at linux.vnet.ibm.com
Mon Nov 28 18:11:10 PST 2011
On 11/28/2011 05:41 PM, Alan Bateman wrote:
> 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?
Yes.
> 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).
>
> -Alan
You are right. The ipv4 will appear in front of ipv6, but the order of
ipv4 or ipv6 (separately) will not be sorted.
--
Yours Charles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/net-dev/attachments/20111129/a7ab9978/attachment.html
More information about the net-dev
mailing list