Converting CIDR address to subnet mask and network address

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);

Leave a Comment