【发布时间】:2022-05-12 14:47:34
【问题描述】:
我在 Java 中搞乱 DNS 服务 - 我专门尝试查找所有 google.com 地址并将它们显示在一个数组中,类似于使用 nslookup 运行查找:
nslookup -q=TXT _netblocks.google.com 8.8.8.8
我为此使用InetAddress,但不断收到异常错误。由于错误涉及“未知主机”,我认为InetAddress 无法读取 TXT 记录(如果我使用 google.com,它可以工作,但不会显示完整的 IP 范围)。以下是我的代码:
InetAddress dnsresult[] = InetAddress.getAllByName("_netblocks.google.com");
for (int i=0; i<dnsresult.length; i++)
System.out.println (dnsresult[i]);
如果有人能指出我正确的方向,将不胜感激。
-JK
【问题讨论】:
-
这个问题可能与Java无关,因为我的
ping也无法解决_netblocks.google.com。 -
谢谢 Zhedar,我知道 :) 我补充说是为了说明我想要做什么。如果我使用 'google.com' 作为我的论点,它会弹出一个 IP。但那是A记录。我需要获取 TXT 记录。
标签: java dns inetaddress