One thing you can try is to use the NetworkInterface class to get the proper InetAddress.