在java中查询dns服务器

时间:2014-09-29 05:00:59

标签: java dns

使用dig查询特定的DNS服务器时,您会得到以下信息: 挖掘@ e.root-servers.net test.it.

;  DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6  @e.root-servers.net test.it
; (1 server found)
;; global options: +cmd
;; Got answer:
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 7, ADDITIONAL: 14
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;test.it.           IN  A

;; AUTHORITY SECTION:
it.         172800  IN  NS  a.dns.it.
it.         172800  IN  NS  c.dns.it.
it.         172800  IN  NS  m.dns.it.
it.         172800  IN  NS  r.dns.it.
it.         172800  IN  NS  s.dns.it.
it.         172800  IN  NS  dns.nic.it.
it.         172800  IN  NS  nameserver.cnr.it.

但是我没有使用dnsjava使用以下java代码获取任何内容。

        Lookup lookup = new Lookup("test.it", Type.NS);
        SimpleResolver resolver=new SimpleResolver("e.root-servers.net");

        //Message msg=new 
        //resolver.send(msg);
        lookup.setDefaultResolver(resolver);
        lookup.setResolver(resolver);
        Record [] records = lookup.run();
        for (int i = 0; i < records.length; i++) {
             Record  r = (Record ) records[i];
            System.out.println(r.getName()+","+r.getAdditionalName());
        }

出了什么问题?

0 个答案:

没有答案