• Post Reply Bookmark Topic Watch Topic
  • New Topic

getHostName question  RSS feed

 
ram ba
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

In my code I have like this.

// Changed the IP to a.b.c.d
InetAddress ad = InetAddress.getByName("a.b.c.d");
ip = ad.getHostAddress();
hn = ad.getHostName();

// ip shows a.b.c.d
// hn also shows a.b.c.d instead of the actual host name.

When I am trying to do the nslookup for this a.b.c.d, I can get the DNS entry and displays the host/canonical name

Can you please tell my why it shows IP and how to get the Hostname itself. Also is there a api that I can use to see if the DNS entry for this IP is missing.

Thanks
 
Lewin Chan
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you nslookup the IP Address?

Perhaps the reverse lookup zones haven't been done correctly.
 
ram ba
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nslookup gives me the correct data for hostname. But not sure why getHostAddress() does not. The same code works for other IPs and not for some.

What is this reverse lookup zones?

Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!