North American Network Operators Group

Date Prev | Date Next | Date Index | Thread Index | Author Index | Historical

Re: DNS Parser

  • From: Paul Vixie
  • Date: Tue Aug 28 13:57:07 2001

> Does anyone know of a simple script that will go through a list of BIND
> primary files, or more and output a list of output like this:
> 
> secondlevel.domain --> address
> thirdlevel.secondlevel.domain --> address
> 
> and so on for several thousand domain files.

I agree with the comment that you ought to use AXFR rather than parsing zone
files, since the zone files can have all kinds of irregularities that make it
a complex job to parse them, whereas an AXFR client will have predictable
output.  Much as it pains me to recommend the use of "nslookup" by anybody for
anything, it has a reasonable way of doing this:

	nslookup <<EOF | awk yada yada
	server $MASTER
	ls -t A $ZONE
	EOF

If you prefer "dig" then you'll shortly be cursing me for its non-optional
shorthand pretty-printing, but once in 1995 when I got done cursing myself
for this misfeature, I wrote $BIND8/contrib/misc/normalize_zone.pl, as in

dig @$SERVER $ZONE axfr | bind8/contrib/misc/normalize_zone.pl | grep ' IN A '

Hope this helps.