是否有 java api 将 ipv6 地址 fd00:: 识别为 local/private?
Is there a java api that will identify the ipv6 address fd00:: as local/private?
我正在寻找 java api 可以正确识别给定 IP 地址是私有地址还是本地地址。此代码似乎适用于大多数 ipv4/ipv6 个地址:
boolean isLocalIp = InetAddress.getByName(ipAddr).isSiteLocalAddress() ||
InetAddress.getByName(ipAddr).isLinkLocalAddress() ||
InetAddress.getByName(ipAddr).isLoopbackAddress() ;
特别是,它将“fec0::”标识为 local/private 类型地址,但不将例如“fc00::”或“fd00::”标识为 local/private 类型地址。
查看此维基百科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.
任何人都可以帮助解释这里是否存在错误假设(例如“fc00::”或“fd00::”应被识别为 local/private ipv6 地址)或者是否存在其他一些java api 将正确识别所有 local/private ip 地址?
感谢任何feedback/answers!
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)
这些块中的地址并不意味着路由到单个管理域之外,但术语 "site-local address" 意味着更具体的东西。这个现已弃用的术语专门指块 fec0::/10.
块 fc00::/7 中的地址 "unique local addresses" 不能保证全局唯一,但它们不是 link-local 因为它们被允许在不同的广播之间路由域。
or if there is some other java api that will correctly identify all local/private ip addresses?
我简要地查看了 InetAddress.isAnyLocalAddress()
,但它的文档似乎与您正在尝试做的不相符。标准库好像没有这样的方法。
我正在寻找 java api 可以正确识别给定 IP 地址是私有地址还是本地地址。此代码似乎适用于大多数 ipv4/ipv6 个地址:
boolean isLocalIp = InetAddress.getByName(ipAddr).isSiteLocalAddress() ||
InetAddress.getByName(ipAddr).isLinkLocalAddress() ||
InetAddress.getByName(ipAddr).isLoopbackAddress() ;
特别是,它将“fec0::”标识为 local/private 类型地址,但不将例如“fc00::”或“fd00::”标识为 local/private 类型地址。
查看此维基百科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.
任何人都可以帮助解释这里是否存在错误假设(例如“fc00::”或“fd00::”应被识别为 local/private ipv6 地址)或者是否存在其他一些java api 将正确识别所有 local/private ip 地址?
感谢任何feedback/answers!
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)
这些块中的地址并不意味着路由到单个管理域之外,但术语 "site-local address" 意味着更具体的东西。这个现已弃用的术语专门指块 fec0::/10.
块 fc00::/7 中的地址 "unique local addresses" 不能保证全局唯一,但它们不是 link-local 因为它们被允许在不同的广播之间路由域。
or if there is some other java api that will correctly identify all local/private ip addresses?
我简要地查看了 InetAddress.isAnyLocalAddress()
,但它的文档似乎与您正在尝试做的不相符。标准库好像没有这样的方法。