IPv6 v IPv4 in Java

It turns out that if your Java app is getting IPv6 addresses back from InetAddress.getLocalHost().getHostAddress() you can use flags to the Java VM to control this behaviour


if you only want IPv4 addresses returned, or


if you need to test your code against IPv6 addresses. These flags are only valid when passed to the JVM when it’s started up (ie they can’t be changed once the App’s running).

Leave a Reply

Your email address will not be published. Required fields are marked *