如何从 JAVA 应用程序中获取所有 DNS 条目?

发布于 2024-07-24 20:34:49 字数 250 浏览 1 评论 0原文

截至目前,我正在使用以下代码来获取给定 IP 地址的 DNS 名称。 我不想为网络中的每个 IP 地址获取它,而是想一次性从 DNS 服务器获取所有 DNS 条目(IP 地址 - 主机名映射)。 是否可以? 如果可以的话,该怎么办呢?

InetAddress addr = InetAddress.getByName(address);
dnsname = addr.getCanonicalHostName().trim();

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幽梦紫曦~ 2024-07-31 20:34:49

无法从公共 DNS 服务器提取其保存的所有数据。 一一枚举所有IP地址是唯一的解决方案。

如果您与 DNS 服务器有特殊关系(例如,由您的雇主管理),您可以向 DNS 管理员请求转移整个区域的权限(该 DNS 请求称为 AXFR)。 他们可能会授权您的 IP 地址或为您提供 TSIG 密钥来验证您的身份。

然后,您必须找到一种方法在 Java 中进行区域传输(可能使用 TSIG 身份验证)。 使用这些关键字,我找到一些代码 和文档。 使用代码搜索引擎,例如 Google 代码搜索Krugle 查找使用示例。

[DNS 专家可能会尖叫“使用在 NSEC 上行走的区域”,但大多数 DNS 区域都没有与 NSEC 签名。]

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文