BIND comes with a tool named-compilezone
that allows you to convert a zone file from binary to text and vice versa.
named-compilezone -f IN_FORMAT -F OUT_FORMAT -o OUT_FILE DOMAIN /PATH/TO/ZONEFILE
To convert a zonefile from binary to text use raw
as the input format and text
as the output format. If you want the output on STDOUT instead of a file use -
as the output file name. Add the option -q
to suppress status output.
Something like this:
named-compilezone -q -f raw -F text -o - example.org /var/lib/bind/zones/db.example.org
should produce output like this:
example.org. 300 IN SOA example.org. admin.example.org. 2020112400 10800 3600 604800 3600
example.org. 300 IN NS ns1.example.org.
example.org. 300 IN NS ns2.example.org.
foo.example.org. 300 IN A 192.168.23.42
...
You can then process the output with the usual text tools (grep
, sed
, awk
, perl
, ...). The presence of a particular A record could for instance be verified like this:
... | grep "^foo\.example\.org.* IN A"