tags:

views:

400

answers:

1

As of now, I'm using the below code to get DNS name of the given IPAddress. Instead of fetching it for each IPAddress in the network, I want to fetch all the DNS entries (IPAddress - HostName mapping) from the DNS Server in one go. Is it possible? If so, how to do it?

InetAddress addr = InetAddress.getByName(address);
dnsname = addr.getCanonicalHostName().trim();
+2  A: 

From a public DNS server, there is no way to pull out all the data it holds. Enumerating all the IP addresses one by one is the only solution.

If you have a special relationship with the DNS server (for instance, it is managed by your employer), you may request from the DNS administrator a right to transfer the whole zone (the DNS request known as AXFR). They may authorize your IP address or gives you a TSIG key to authentify yourself.

Then, you will have to find a way to do a zone transfer (possibly with TSIG authentication) in Java. Using these keywords, I find some code and documentation. Use a code search engine like Google Code Search or Krugle to find examples of use.

[DNS experts will probably scream "Use zone walking on NSEC" but most DNS zones are not signed with NSEC.]

bortzmeyer
Thanks for the links. Initial reading of links and some test code shows that it can be achieved. I am yet to try it with TSIG key. I will post here once I am successful.
Jay