Aug
10
2013
bind: dump named db and split it into zone files

bind has a nice command to dump all the records (cache, views and zones) of a bind dns server to a single file.


> rndc --help

  dumpdb [-all|-cache|-zones] [view ...]
                Dump cache(s) to the dump file (named_dump.db).

Our named_dump.db file has 3.5m lines.

I was looking for a simple way to parse this entire formatted file and split the content of the zones to bind formatted zone files (for another project). So i was looking to implement the exactly opposite from: rndc dump --zones

i came with this:


grep 'IN' named_dump.db | awk -F[\'\/] '/Zone dump of/ {out=$2;}{print > out;}'

PS: The reason i am doing that, is that we dont have the 41435 zones to strict formatted bind zone files.
Some of them have “A” against “IN A”, some of them dont have TTL on RR (so the master TTL is in place), some of them use ‘@’ for origin etc etc etc. This is acceptable from bind, not really hard to parse when you are programming a custom provisioning mechanism.

Tag(s): bind, awk