I'm trying to query again a particular dns server both in linux shell using digg and using Java. The dig command works. but the java way doesn't. what's wrong?
dig @dns.nic.it test.it ;; QUESTION SECTION: ;test.it. IN A ;; AUTHORITY SECTION: test.it. 10800 IN NS dns2.technorail.com. test.it. 10800 IN NS dns.technorail.com. test.it. 10800 IN NS dns3.arubadns.net. test.it. 10800 IN NS dns4.arubadns.cz.
java way
public static void rootDNSLookup(String domainName) throws NamingException{ String server="dns://dns.nic.it"; Hashtable env = new Hashtable(); env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory"); env.put("java.naming.provider.url", server); DirContext ictx = new InitialDirContext(env); Attributes attrs = ictx.getAttributes(domainName, new String[] {"A", "AAAA", "NS", "SRV"}); System.out.println(attrs); NamingEnumeration e = attrs.getAll(); while(e.hasMoreElements()) { Attribute a = e.next(); System.out.println(a.getID() + " = " + a.get()); } }
java prints:
No attributes