Given a CIDR address, e.g. 192.168.10.0/24
192.168.10.0/24
24
255.255.255.0
192.168.10.0
It is covered by apache utils.
See this URL: http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/util/SubnetUtils.html
String subnet = "192.168.0.3/31"; SubnetUtils utils = new SubnetUtils(subnet); utils.getInfo().isInRange(address)
Note: For use w/ /32 CIDR subnets, for exemple, one needs to add the following declaration :
utils.setInclusiveHostCount(true);
2.1m questions
2.1m answers
60 comments
57.0k users