File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes InetAddress Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "InetAddress" Watch "InetAddress" New topic


Shaili Suri

Joined: Dec 12, 2003
Posts: 2
I need help in resolving IP address of a supplied server name. Currently, the application is using InetAddress.getHostAddress() to extract IP address from provided server name.
The problem here is this returns the private IP address of the server name. If I need the public IP address, then what should I use?
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
i am not absolutly sure about that. But the java classes simply use the operating systems host resolving method. (hosts file, DNS etc.).
so it will always give you the same ip like e.g.
# ping
If you want to have a different ip to be retrieved just change the names
I agree. Here's the link:
subject: InetAddress
It's not a secret anymore!