IPUtil { public static boolean isValidIPRange( String ipStart, String ipEnd, String ipToCheck ) { try { if ( "*".equals( ipStart ) || "".equals( ipStart ) ) { return true; } else { long ipLo = ipToLong( InetAddress.getByName( ipStart ) ); long ipHi = ipToLong( InetAddress.getByName( ipEnd ) ); long ipToTest = ipToLong( InetAddress.getByName( ipToCheck ) ); return ipToTest >= ipLo && ipToTest <= ipHi; } } catch ( Exception e ) { LOGGER.error( "Error parsing InetAddress", e ); return false; } }  static boolean isValidIPRange( String ipStart, String ipEnd, String ipToCheck ); static boolean isValid( final String ip ); static String getLocalIpByInterfaceName( String interfaceName ); static Set<String> getLocalIps(); static String getNetworkAddress( String ip ); HostInterface findInterfaceByName( Set<HostInterface> allInterfaces, String interfaceName ); static HostInterface getInterfaceByName( Set<HostInterface> allInterfaces, String interfaceName ); static boolean isIpValid( HostInterface hostInterface );  }
@Test public void testIsValidIPRange() throws Exception { assertTrue( ipUtil.isValidIPRange( "*", "*", "172.5.5.5.5" ) ); assertTrue( ipUtil.isValidIPRange( "10.10.10.1", "10.10.10.10", "10.10.10.5" ) ); }