Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPv6 validation

I used IPAddressUtil.isIPv6LiteralAddress (ipAddress) method to validate IPv6, but this method fails for ipv6-address/prefix-length format (format is mentioned in RFC 4291 section 2.3) of IPV6.

Could anyone know any validators which validate " ipv6-address/prefix-length " format?

Legal representations of IPV6

  1. ABCD:EF01:2345:6789:ABCD:EF01:2345:6789
  2. 2001:DB8:0:0:8:800:200C:417A
  3. FF01:0:0:0:0:0:0:101
  4. 0:0:0:0:0:0:0:1
  5. 0:0:0:0:0:0:0:0
  6. 2001:DB8::8:800:200C:417A
  7. FF01::101
  8. ::1
  9. ::
  10. 0:0:0:0:0:0:13.1.68.3
  11. 0:0:0:0:0:FFFF:129.144.52.38
  12. ::13.1.68.3
  13. FFFF:129.144.52.38
  14. 2001:0DB8:0000:CD30:0000:0000:0000:0000/60
  15. 2001:0DB8::CD30:0:0:0:0/60
  16. 2001:0DB8:0:CD30::/60

NOT legal representations of IPV6

  1. 2001:0DB8:0:CD3/60
  2. 2001:0DB8::CD30/60
  3. 2001:0DB8::CD3/60
like image 488
Isabel Jinson Avatar asked May 11 '11 11:05

Isabel Jinson


People also ask

How do I know if my IPv6 is valid?

Typically strings, that do *not* trepresent a valid IPv6 address have characters other than the hex-digits in it, or they consists of less than 8 blocks of hexdigits, or they have at least one block of hexdigits in it with more than 4 hex-digits, or they have more than one position in it, where 2 colons directly follow ...

Is :: valid IPv6 address?

The following are examples of valid IPv6 (normal) addresses: 2001:db8:3333:4444:5555:6666:7777:8888. 2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF. :: (implies all 8 segments are zero)

Which is not a valid IPv6 address?

The addresses 255.1. 4.2 and fe80:2030:31:24 are not valid IPv6 addresses.

How do I find my IPv6 address?

Type “ipconfig/all” on the blinking cursor then press [Enter]. NOTE: You will find the IPv6 Address network details under the Ethernet adapter Local Area Connection section.


1 Answers

You can use the Guava library, specifically using the com.google.common.net.InetAddresses class, calling isInetAddress().


isInetAddress

public static boolean isInetAddress(String ipString)

Returns true if the supplied string is a valid IP string literal, false otherwise.

Parameters: ipString - String to evaluated as an IP string literal

Returns: true if the argument is a valid IP string literal

like image 187
broc.seib Avatar answered Oct 07 '22 16:10

broc.seib