Java library to check if IPv4 or IPv6 address is in a given subnet
问题 What library can I use to check if an IP address is in a given subnet? I could find libraries like the Apache Commons SubnetUtils (SubnetUtils.SubnetInfo.isInRange) but many do not support IPv6 yet. 回答1: edazdarevic's CIDRUtils supports both IPv4 and IPv6. The example does not mention boolean isInRange(String ipAddress), but it is implemented! Another option is java-ipv6, but it does not support IPv4 and requires JDK7. 回答2: Use spring-security-web 's IpAddressMatcher. Unlike Apache Commons