Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-651

Ip Range Check with SubnetUtils provides incorrect answer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • None
    • None
    • None
    • None

    Description

      private static void checkIp() {
       System.out.println(verifyCommonsNet("192.168.0.1", "192.168.0.1/32"));
       System.out.println(verifySpringSecurity("192.168.0.1", "192.168.0.1/32"));
      }
      
      private static boolean verifyCommonsNet(String ip, String subnet) {
       SubnetUtils.SubnetInfo subnetInfo = (new SubnetUtils(subnet)).getInfo();
       return subnetInfo.isInRange(ip);
      }
      
      private static boolean verifySpringSecurity(String ip, String subnet) {
       IpAddressMatcher ipAddressMatcher = new IpAddressMatcher(subnet);
       return ipAddressMatcher.matches(ip);
      }

       

      Tried to check Ip range functionality with Subnet Utils. But I get an incorrect answer when using mask of 32. The same CIDR with Spring security provides the right answer. checking 192.168.0.1 against 192.168.0.1/32 should return true. 

      Attachments

        Activity

          People

            Unassigned Unassigned
            sathyam sathyam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: