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. 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 . Use spring-security-web 's IpAddressMatcher . Unlike Apache Commons Net, it supports both ipv4 and ipv6. import org.springframework.security.web.util.matcher.IpAddressMatcher; ..