DNS Parser

Since IP allocations have been such a hot topic lately, I thought I'd ask
this --

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.

We acquired a company that never kept their reverses up to date and need a
simple way of building them to keep track of their IP utilizations.

There is probably one written in perl out there somewhere, I'd appreciate a
pointer.

Thanks,

Deepak Jain
AiNET

We use dnslex here to handle all of that.
I simply edit the zone file, check it back in, go to the directory below,
and do a "make", and then a named.reload. Good to go.

/nick

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.

We acquired a company that never kept their reverses up to date and need a
simple way of building them to keep track of their IP utilizations.

There is probably one written in perl out there somewhere, I'd appreciate a
pointer.

it would probably be easy enough to throw one together, however, i'd
suggest sucking all the zones directly out of bind via axfr instead of
reading the zone files directly. that "normalizes" the output to
something you can pass through grep rather easily. ex:

   % dig example.com axfr @192.168.189.7 | grep '\<IN.A\>'
   home 5M IN A 192.168.189.65
   localhost 1D IN A 127.0.0.1
   www 5M IN A 192.168.189.72
   wombat 5M IN A 192.168.189.65
   %

from there it's only a short hop to reversing the information.

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.

[ On , August 28, 2001 at 10:50:53 (-0700), Paul Vixie wrote: ]

Subject: Re: DNS Parser

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

The new version of host (i.e. the one that's usually only slightly out
of date in the BIND contrib directory, NOT the junky old useless one in
the main BIND src/bin directory) is much less painful to recommend (and
has equally regular and predictable output):

  host -a -l $ZONE $SERVER | awk 'blah'

You can of course have 'host' do the filtering for only specific types
of records too. For example to display only 'A' records:

  host -t a -l $ZONE $SERVER | awk 'blah'

You can even omit the $SERVER parameter and 'host' will try all the
authoritative servers until it succeeds.