How to get all IP adresses of a Linux machine using Java?
My device has two IP adresses, but while trying to get all IP addresses by using the below, it will return only a primary IP address. The same piece of code works fine for Windows.
InetAddress myAddr = InetAddress.getLocalHost();
System.out.println("myaddr::::" + myAddr.getHostName());
InetAddress localAddress[] = InetAddress.getAllByName(myAddr.getHostName());
int len = localAddress.length;
for(int i = 0; i < len; i++)
{
String localaddress = localAddress[i].getHostAddress().trim();
System.out.println("localaddress::::" + localaddress);
}