Guidelines

This site is for tech Q&A. Please keep your posts focused on the subject at hand.

Ask one question at a time. Don't conflate multiple problems into a single question.

Make sure to include all relevant information in your posts. Try to avoid linking to external sites.

Links to documentation are fine, but in addition you should also quote the relevant parts in your posts.

0 votes
13.6k views
13.6k views

I'm running BIND as a DNS slave and want to check if the zone contains the correct records after an update on the master. However, the zone file appears to be binary:

root@server:/var/lib/bind/zones# file db.example.org
db.example.org: data
root@server:/var/lib/bind/zones# hexdump -C db.example.org
00000000  00 00 00 02 00 00 00 01  5f bc cb d0 00 00 00 00  |........_.......|
00000010  00 00 00 00 00 00 00 00  00 00 00 72 00 01 00 06  |...........r....|
...

Is there a way to check this file for the presence (or absence) of particular records?

in Sysadmin
edited by
by (125)
3 19 33
edit history

Please log in or register to answer this question.

1 Answer

0 votes
 

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"
by (125)
3 19 33
edit history
...