JAVA中的DNS查询 [英] DNS query in JAVA

查看:226
本文介绍了JAVA中的DNS查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用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); (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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆