How to fetch all DNS entries from JAVA application?

依然范特西╮ 提交于 2019-12-24 10:47:35

问题


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();

回答1:


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.]



来源:https://stackoverflow.com/questions/999743/how-to-fetch-all-dns-entries-from-java-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!