InetAddress just does a lookup on your hostname to determine your local host 
address.  If your host name resolves to 127.0.0.1 (for instance, if the first 
entry in your /etc/hosts file maps 127.0.0.1 to your hostname rather than just 
to localhost and localhost.localdomain), then that's the IP address you'll get.

Unfortunately, there's no way in Java to get any more information about the 
network addresses on your system.  So you pretty much have to fix your hosts 
files.  (And no, InetAddress.getAllByName(String host) doesn't do what you 
think it does--it returns all the IP's that answer to a given hostname, rather 
than the addresses of all the interfaces on a multi-homed system.)

Good luck.

-allen

On Tue, Dec 05, 2000, 13:44, Francisco Gongora <[EMAIL PROTECTED]> wrote
>Hello:
>I have this situation: in my local network I have several machines in NT,
>Solaris and Linux.  My java application is running well in all the platforms
>including Linux.  One of the Linux machines, however, is reporting the local
>address instead of the ip address when I do:
>
>               InetAddress.getLocalHost();
>
>For the rest of the machines I get the real ip address ie. 192.#.#.96,
>however, for this Linux machine I get 127.0.0.1 which is the local address.
>Looking at the host file in the linux machines, we have some differences
>which may be causing this problem, but this file is suppose to be edited by
>the user.
>
>Is it there any way to get the true ip address of a Linux machine regardless
>the explicit configuration placed on the host file?
>
>Thanks
>Francisco.
>
>
>
>
>----------------------------------------------------------------------
>To UNSUBSCRIBE, email to [EMAIL PROTECTED]
>with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
>


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to