I would like to have all locally bound IP addresses, basically an array of java.net.InetAddress. I know I can call InetAddress.getAllByName() with the host name, but I was wondering if there is a more direct way that doesn't involve DNS and/or knowledge of the host name.
Asked
Active
Viewed 1,545 times
2
-
Take a look at this threat: http://stackoverflow.com/questions/1062041/ip-address-not-obtained-in-java – Martijn Courteaux Dec 01 '09 at 16:59
1 Answers
4
java.net.NetworkInterface.getNetworkInterfaces()
will give you an enumeration of the available network interfaces. You can then invoke getInetAddresses()
on each NetworkInterface to get the addresses bound to this interface.

jarnbjo
- 33,923
- 7
- 70
- 94