What does InetAddress.isSiteLocalAddress() actually mean?
The method is definitely not deprecated and it's definitely not just used in IPv6.
In IPv4 there are 3 network address ranges that are defined for site-local addresses: 10/8, 172.16/12 and 192.168/16.
Reading Inet4Address.isSiteLocalAddress()
shows that addresses from exactly those 3 networks will return true
on those methods.
IPv6 has a similar concept, here these addresses are called unique local addresses.
Effectively this tells you if the address you have is definitely not a public one (note that even if this method returns false
, the address might still not be public).
Looking at the implementation...
For an Inet4Address
, it checks to see if it's one of the RFC1918 "unrouteable" addresses: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
For an Inet6Address
, it checks the first two octets to see if it's a real "site local" address.