Skip to content

Instantly share code, notes, and snippets.

@wido
Created January 16, 2019 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wido/948ece578864f8de3d5e145853bf5e32 to your computer and use it in GitHub Desktop.
Save wido/948ece578864f8de3d5e145853bf5e32 to your computer and use it in GitHub Desktop.
Check if IPv6 Address is EUI-64 in Java
import com.googlecode.ipv6.IPv6Address;
/*
Replace the IPv6 address with anything you like, Link Local or Global, based on the 'ff:fe' in the address
this code will tell you if the address is EUI-64
Author: Wido den Hollander <wido@widodh.nl>
*/
public class IPv6 {
public static void main(String[] args) {
String address = "fe80::800:27ff:fe00:0";
IPv6Address addr = IPv6Address.fromString(address);
byte[] bytes = addr.toByteArray();
if (bytes[11] == -1 && bytes[12] == -2) {
System.out.println("True");
} else {
System.out.println("False");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment