Silly Unix Tricks #1: De-crufting Bind9 configuration files

February 18, 2009 | Comments Off

I’d like to resume writing occasionally, so the first one will be brief. Trying to debug a DNS problem tonight, I realized my BIND9 configuration file (named.conf) had accumulated too much cruft over the years. Unfortunately, the C/C++ comment style made it difficult to grep the useful bits. cpp to the rescue:

janus:/var/cache/bind/master# wc -l master-zones.conf
100 master-zones.conf
janus:/var/cache/bind/master# cpp master-zones.conf  | wc -l
49

This cleans up the file nicely. Of course, you’ll have to add the useful comments back in.