8

Is there a way to get a complete list of A and CNAME records on my BIND DNS server?

I have access to the zone files. But on my server there are lots of zone files, and it'd take too long to go over all of them by hand. Is there a command that lists this info or will I have to write a script myself?

chroder
  • 664
  • 2
  • 8
  • 17

3 Answers3

10

Rather than use grep on all of the zone files, use:

% rndc dumpdb -zones

This will create a dump of the server's authoritative data called named_dump.db, probably in /var/named/data (or similar).

This file is easier to parse than the original zone files because every line starts with the domain name to which it applies. The raw zone files are probably abbreviated.

Alnitak
  • 21,191
  • 3
  • 52
  • 82
1

From your var/named/data (or equivalent directory) grep through the db.* files with an appropriate regular expression, something like:

grep '\(.  *A   *[0-9][0-9]*\)\|\(..*CNAME..*\)' db.*

Note that the final 'db.*` globs all the db files. Repeat for every directory you have zone files in.

-2

for i in my domain list; do dig -t axfr $i @localhost; done

Have to allow zone transfers from localhost first.

dmourati
  • 25,540
  • 2
  • 42
  • 72