I am trying to get my Internet IP address in Java but I keep getting my local address (ie: 127.0.0.1), when my IP address is 192.168.0.xxx
I am using the line:
Another option for default network interface, just I was trying 5 min ago and saw your question :)
InetAddress[] localaddr;
try {
localaddr = InetAddress.getAllByName("host.name");
for(int i = 0; i < localaddr.length; i++){
System.out.println("\n" + localaddr[i].getHostAddress());
}
} catch (UnknownHostException e) {
e.printStackTrace();
}