[ACCEPTED]-What does InetAddress.isSiteLocalAddress() actually mean?-inet
The method is definitely not deprecated and it's definitely not just 9 used in IPv6.
In IPv4 there are 3 network address ranges that are defined for site-local addresses: 10/8, 172.16/12 8 and 192.168/16.
Reading Inet4Address.isSiteLocalAddress()
shows that addresses 7 from exactly those 3 networks will return 6 true
on those methods.
IPv6 has a similar concept, here 5 these addresses are called unqieu local addresses.
Effectively 4 this tells you if the address you have is 3 definitely not a public one (note that even 2 if this method returns false
, the address might 1 still not be public).
Looking at the implementation...
For an Inet4Address
, it 4 checks to see if it's one of the RFC1918 3 "unrouteable" addresses: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
For 2 an Inet6Address
, it checks the first two octets to see 1 if it's a real "site local" address.
'Site local' is a deprecated name for private 2 IP space. (Some nuances, but basically right.) See 1 RFC 1918.
I just came across what I believe is a similar 13 problem: trying to determine what IPv6 I should use for LAN comuncation:
IMHO,
Inet6Address.isSiteLocalAddress()
is useless. Given that 12 the0xFEC0
prefix has been depricated by RFC 3879 as @tigz 11 mentioned. I have yet to see any device 10 (android, win, osx) actually have a0xFEC0
(with 9 limited testing)//from java.net.Inet6Address (1.8.0_45) boolean isSiteLocalAddress() { return ((ipaddress[0] & 0xff) == 0xfe && (ipaddress[1] & 0xc0) == 0xc0); }
0xFE80
address although not supposed 8 be used for traffic (from my understanding 7 and reading (www.cisco.com)) did work for LAN communication 6 with my single router (ping6, curl, http).My 5 Global Unicast (which is just another name 4 for public IP)
2601::/20
from Comcast worked for 3 my LAN communication. So I would say that 2 this is the correct address to use.
Prefix 1 table: www.iana.org
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.