Search code examples
javaguavaipv6apache-commons

How to validate IPv6 which has scope ID?


I tried apache commons validator and Guava. Both libraries return invalid for an IPv6 address which has scope ID(%15 in given example) in it. eg. fe80::8b2:d61e:e5c:b333%15

Is there any java library which considers it a valid IPv6 address?


Solution

  • Standard java.net classes InetAddress/Inet6Address seem to parse it correctly, e.g.

    InetAddress inet6Address = Inet6Address.getByName("fe80::8b2:d61e:e5c:b333%15"); 
    

    btw. indeed AC (1.5.1) InetAddressValidator and Guava (19.0) InetAddresses seem to fail on this