title: Get complete zone records from DNS, DNSJava doesn't return all records
body: <p>Good afternoon,</p>
  
  <p>I'm working on a network discovery effort, and need to get all records for a domain.  When I use DNSJava, its not the complete set.  CNAME's aren't present, and not all TXT records, or A records.</p>
  
  <p>Is there a better way to go about this?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>    package iMCDNS;
      import java.util.Hashtable;
  
      import javax.naming.Context;
      import javax.naming.NamingEnumeration;
      import javax.naming.directory.Attribute;
      import javax.naming.directory.Attributes;
      import javax.naming.directory.DirContext;
      import javax.naming.directory.InitialDirContext;
  
      import org.xbill.DNS.Lookup;
      import org.xbill.DNS.Record;
      import org.xbill.DNS.Type;
  
      public class iMCDNS {
  
      public static void main(String[] args) {
  
          System.out.println("Running iMCDNS");
  
          try {
  
              //this returned no records
  
  //          DirContext ctx = new InitialDirContext(env);
  //          Attributes atts = ctx.getAttributes("iditsecurity.com", new String[] {"CNAME"});
  //          
  //          System.out.println("Attributes size: " + atts.size());
  //
  //          NamingEnumeration&lt;? extends Attribute&gt; e = atts.getAll();
  //          
  //          
  //          while(e.hasMore()) {
  //              System.out.println(e.next().get());
  //          }
  
              //this also returns no CNAME records
              Record[] rs = new Lookup("iditsecurity.com", Type.ANY).run();
  
              if (rs!=null)
              {
                  int javaDNSLen = rs.length;
  
                  for (int i = 0;i &lt; javaDNSLen; i++)
                  {
                      System.out.println("record: " + rs[i].toString());
                  }
  
              } else {
                  System.out.println("No records found");
              }
  
          } catch (Exception ex) {
  
              System.out.println("Exception occurred: " + ex.toString());
          }
  
  
  
      }
  
  
  
  
      }
  </code></pre>
  
  <p>And the results provided:
  Should have 2 A records, 4 CNAME and 5 TXT records...</p>
  
  <pre><code>Running iMCDNS
  record: iditsecurity.com.   4503    IN  TXT "google-site-verification=VvXfVc-hr0dK3pzjc3yiAaDsK-tlFAMX7Xt3soYXByc"
  record: iditsecurity.com.   4503    IN  TXT "google-site-verification=8W17El_6uLvJ0WLxEsgIKt9hKRPuz6yN9U_ke9l0i7E"
  record: iditsecurity.com.   4360    IN  MX  10 mx1.netsolmail.net.
  </code></pre>