Affect the order of NetworkInterface.getNetworkInterfaces enumeration in Java 6 on Linux
问题 What is the order in which NetworkInterface.getNetworkInterfaces() returns an enumeration of network interfaces? Is there a way to affect that on JVM level or on Linux OS level? 回答1: According to the source of the OpenJDK (found in src/solaris/native/java/net/NetworkInterface.c, method enumInterfaces ) it will return IPv4 interfaces first (method enumIPv4Interfaces ), followed by IPv6 interfaces (method enumIPv6Interfaces ). The order within those categories seems to be the same that the OS