Unique Host ID
I'm looking for a cross-platform way for hosts to self-generate an id which will (with medium/high certainty) be unique on the Internet and consistent between program executions without storing to disk.
The ideal solution would be to use a MAC address from one of the system's network devices, but I can't find a clean platform-neutral way of finding these,
If there is a solution which will survive restarting the JVM but not a system reboot, that would work also.
[487 byte] By [
lannma] at [2007-11-27 9:00:47]

That is my backup strategy, but if I do that I have to make sure its an external IP, as the system could be NATed and lots of NATed hosts have similar IPs (e.g. 192.168.1.x).
That would mean a call to an outside service that provides external IP lookup, which means hard-coding a site that could go down.
lannma at 2007-7-12 21:29:53 >

It's a bit of a hack:
if(System.getProperty("java.vm.version").startsWith("1.6")) {
System.out.println("Found 1.6!");
} else {
System.out.println("Found something old...");
}
I think this should work:
try {
unique = if.getHardwareAddress();
} catch (NoSuchMethodException e) {
unique = getExternalIp();
}
lannma at 2007-7-12 21:29:53 >
