Reverse DNS lookup Help
Hi All,
In my java application i use the "InetAddress" class for resolving the IPAddresses into Hostnames. Below is my implementation method,
public String getHostNameFromIP(String ipaddr)
{
String dnsName = ipaddr;
try
{
InetAddress addr = InetAddress.getByName(ipaddr);
dnsName = addr.getCanonicalHostName().trim();
System.out.println("CanonicalName............:" + dnsName);
//dnsName = addr.getHostName().trim();
//System.out.println("HostName..................:" + dnsName);
}catch(Exception e)
{
e.printStackTrace();
}
return dnsName;
}
Below are my queries,
1. Can i get the hostname from IPAddresses[My input is only IPAddress] using otherthan 'InetAddress' class from JAVA.
2. Above method doesn't give me the proper results for my list of IPAddresses [Internal and External IP's] but the 'nslookup' will resolve all IPAddresses. Why 'InetAddress' class not give me the proper results?
Please note that i tried with DNS and HostName configuration for DHCP setup as well as in static IP setup [Windows XP]
Please pour your views.
Thanks,
Saravanan.H
[1218 byte] By [
saran@suna] at [2007-11-27 7:59:28]

> 1. Can i get the hostname from
> IPAddresses[My input is only IPAddress] using
> otherthan 'InetAddress' class from JAVA.
Why?
> 2. Above method doesn't give me the proper
> results for my list of IPAddresses [Internal and
> External IP's] but the 'nslookup' will resolve all
> IPAddresses. Why 'InetAddress' class not give me the
> proper results?
Misconfigured /etc/hosts file or DNS system?
ejpa at 2007-7-12 19:41:31 >

Hi,
First I thank you prompt response on my queries.
1. I am working for a banking project, where i can get a list of IP's as input [ Internal and External] who access the system and try to resolve the IP's using the above method and try to show the list of Hosts [Internal Hosts (or) ISP incase of LAN Ip's]. Because of not getting the proper HostName for some IP's, I want to try with other Java Classes.
Please note that i don't assume any default ports should run on every IP's inorder to use Socket class.
2. Then how my 'nslookup' will give me the proper results for the non resolving IP's by InetAddress. In API documentation of 'InetAddress' class, I read that this class[getByName()] will work similar to 'nslookup' and produce the results.
I am sure that the configurations are fine in my Windows XP.
Thanks,
Saravanan.H