I'm looking for a java api that will correctly identify if a given ip address is private or local. This code seems to work for most ipv4/ipv6 addresses:
boolean isLocalIp = InetAddress.getByName(ipAddr).isSiteLocalAddress() ||
InetAddress.getByName(ipAddr).isLinkLocalAddress() ||
InetAddress.getByName(ipAddr).isLoopbackAddress() ;
Particularly, it identifies "fec0::" as a local/private type address but it does not identify, for example, "fc00::" or "fd00::" as local/private type addresses.
Looking at this wikipedia link https://en.wikipedia.org/wiki/Private_network#IPv6:
The address block fc00::/7 is reserved by IANA for Unique Local Addresses (ULA).[2] They are unicast addresses, but contain a 40-bit random number in the routing prefix to prevent collisions when two private networks are interconnected. Despite being inherently local in usage, the IPv6 address scope of unique local addresses is global.
The first block defined is fd00::/8, designed for /48 routing blocks, in which users can create multiple subnets, as needed.
Can anyone help with explaining if there is some false assumption here (e.g. that "fc00::" or "fd00::" should be identified as a local/private ipv6 address) or if there is some other java api that will correctly identify all local/private ip addresses?
Thanks for any feedback/answers!