A
Amankwah
I used the InetAddress.getLocalHost() to get my IP address, buy i got
127.0.1.1?
How can i get my REAL ip address?
127.0.1.1?
How can i get my REAL ip address?
I used the InetAddress.getLocalHost() to get my IP address, buy i
got 127.0.1.1? How can i get my REAL ip address?
Amankwah said:I used the InetAddress.getLocalHost() to get my IP address, buy i got
127.0.1.1?
How can i get my REAL ip address?
I used the InetAddress.getLocalHost() to get my IP address, buy i got
127.0.1.1?
How can i get my REAL ip address?
Are you using a Debian-based distribution of Linux? IIRC, when recent
Debian releases are using DHCP, in order to give a consistently
functioning IP address it uses this address. I think this is necessary
for Gnome. Addresses in the 127 class-A network should never appear on
the (physical) wire.
The obvious solution is not to use dynamic IP assignment, but that is
perhaps not very helpful.
I tried getAllByName using my hostname, but only got the one result
(using Ubuntu 7.04).
From 1.6, it appears with a little experimentation that you can get
java.net.NetworkInterface to get the information.
for (
java.util.Enumeration<NetworkInterface> en =
NetworkInterface.getNetworkInterfaces();
en.hasMoreElements();
) {
NetworkInterface iface = en.nextElement();
System.err.println(iface.getInterfaceAddresses());
}
I have absolutely no idea why an interface introduced in 1.6 is still
using Enumeration.
Tom Hawtin
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.