How to retrieve host name from ip address ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Hemant_Gandhi
Posted On:   Tuesday, September 24, 2002 03:20 AM

How can I retrieve the host name if I know the IP address.

I tried String host = InetAddress.getByName("202.67.89.98").getHostName();
but it does not work.
It just returns the same IP address as passed to it. Please help.

Re: How to retrieve host name from ip address ?

Posted By:   Christopher_Koenigsberg  
Posted On:   Tuesday, September 24, 2002 06:45 AM

The way DNS works, there needs to be a reverse PTR record in the DNS database, mapping that IP address to a single hostname, in the first place, or you're out of luck (often many hostnames are mapped, via A and CNAME records, all to the same address; so an explicit PTR record is necessary, to single out just one of them, for your reverse mapping from the address to a canonical name).



Reasonable sites should have reverse PTR records in their DNS database, for all their IP addresses, but not all sites are reasonable in this way.

About | Sitemap | Contact