ankur rathi wrote:
Is there anyway to determine hostname from ip address?
I checked some websites but our ips are "unknown" to them, may be some firewall thing.
Peter Johnson wrote:Sometimes you can use "ping -a" to resolve the hostname for an IP address.
but I can't access those ips from my local system
xsunil kumar wrote:Rathi, You can use below small java program to get host name from IP.
try
{
java.net.InetAddress inetAdd = java.net.InetAddress.getByName("206.190.60.37");
//127.0.0.1 is loop back address
System.out.println ("Hostname is: " + inetAdd.getHostName());
}
catch(java.net.UnknownHostException uhe)
{
//handle exception
}
-Sunil
Peter Johnson wrote:
but I can't access those ips from my local system
Then it is impossible to find out the host names in the usual manner (using network commands, or the code xsunil provided).
Pat Farrell wrote:
Peter Johnson wrote:
but I can't access those ips from my local system
Then it is impossible to find out the host names in the usual manner (using network commands, or the code xsunil provided).
Are you sure? A normal reverse DNS lookup should give you the results even if you can't access the particular IP addresses. This assumes, of course, that the IP addresses in question actually resolve to a hostname, and that the reverse DNS is configured properly.
Note: folks upthread are talking about using PING, in a slightly incorrect way. Ping is a network test which is handy, but it is not necessary. Ping is a separate protocol and is often blocked by firewalls, etc. You do *not* need to be able to ping a host to be able to talk to it via TCP/IP
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
James Sabre wrote:Much of this thread assumes that there is a 1-1 relationship between IP address and domain name. This is not the case. My fixed IP address has 4 domain names so given the IP address which domain name should be returned in any lookup?
LOOK! OVER THERE! (yoink) your tiny ad is now my tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|