JAVA中的DNS查询 [英] DNS query in JAVA
问题描述
nslookup -q = TXT _netblocks.google.com 8.8.8.8
我正在使用 InetAddress
,但继续收到异常错误。由于错误是指未知主机,我不认为 InetAddress
可以读取TXT记录(如果我使用google.com它的工作,但这并没有显示完整的IP范围)。以下是我的代码:
InetAddress dnsresult [] = InetAddress.getAllByName(_ netblocks.google.com); (int i = 0; i< dnsresult.length; i ++)
System.out.println(dnsresult [i]);
如果有人可以指出我正确的方向,不妨感谢。
-JK
InetAddress
不这样做,但您可以通过 JNDI DNS提供商。
I am messing around with DNS services in Java - I am specifically trying to lookup all google.com addresses and display them in an array, similar to running a lookup using nslookup:
nslookup -q=TXT _netblocks.google.com 8.8.8.8
I am using InetAddress
for this but keep on getting exception errors. Since the errors refer to 'Unknown Host' I don't think InetAddress
can read TXT records (if I use google.com it works, but that does't show the full IP Range). Below is my code:
InetAddress dnsresult[] = InetAddress.getAllByName("_netblocks.google.com");
for (int i=0; i<dnsresult.length; i++)
System.out.println (dnsresult[i]);
Would appreciate it if someone can point me in the right direction.
-JK
InetAddress
doesn't do this, but you can accomplish DNS TXT record lookups in Java via the JNDI DNS provider.
这篇关于JAVA中的DNS查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!