public static boolean isInRange(String ip,String ipRange){
  if (ip == null || ipRange == null)   return false;
  String[] cidrString=ipRange.split("/");
  if (cidrString.length == 0)   return false;
  String network=cidrString[0];
  String cidrMask="24";
  if (cidrString.length > 1) {
    cidrMask=cidrString[1];
  }
  String netMask=cidrMaskToNetMask(cidrMask);
  InetAddress maskedIP=applyMask(ip,netMask);
  InetAddress maskedNetwork=applyMask(network,netMask);
  if (maskedIP == null || maskedNetwork == null)   return false;
  return maskedIP.equals(maskedNetwork);
}

public static boolean isInRange ( String ip , String ipRange ) { if ( ip == null || ipRange == null ) return false ; String [ ] cidrString = ipRange . split ( "/" ) ; if ( cidrString . length == 0 ) return false ; String network = cidrString [ 0 ] ; String cidrMask = "24" ; if ( cidrString . length > 1 ) { cidrMask = cidrString [ 1 ] ; } String netMask = cidrMaskToNetMask ( cidrMask ) ; InetAddress maskedIP = applyMask ( ip , netMask ) ; InetAddress maskedNetwork = applyMask ( network , netMask ) ; if ( maskedIP == null || maskedNetwork == null ) return false ; return maskedIP . equals ( maskedNetwork ) ; }
tells whether the given ipv4 address is in the given cidr ip range
