12

A DNS Master zone file has been transferred to a slave, but I cannot read the zone file:

> less db.example.com

"db.example.com "may be a binary file.  See it anyway?

This happened after I used this command:

cp -r /usr/local/sbin/* /usr/sbin/.

I installed bind V.9.9 instead of V.9.6. I would like to be able to read the zone file as plain text.

Eborbob
  • 213
  • 3
  • 13
user1044942
  • 139
  • 1
  • 1
  • 3
  • 6
    Why did you `cp -r /usr/local/sbin/* /usr/sbin/.`??? – gevial Mar 15 '13 at 10:09
  • 1
    I would say: reinstall your server and everything. The short-cut might be to just re-install "world" (or the "sbin" part) and remove all the added file from "/usr/local/sbin". – Ouki Mar 15 '13 at 11:54
  • Is that DNS file really a binary file (or is there some control chars that makes "less" mismatching it) ? – Ouki Mar 15 '13 at 11:55
  • it could be something simple, such as non-printable control characters in the file, or your zone data on the slaves might really be being stored in raw format, since you are using BIND 9.9, in which case see my answer below -- you can use named.compilezone to change from one format to another if you just want to look at the file. – Michael McNally Mar 16 '13 at 03:54

2 Answers2

28

Slave zone data files in BIND 9.9 are in "raw" format by default. You can convert "raw" format zone files to "text" format using the named-compilezone utility that comes with BIND.

raw to text:

# convert raw zone file "example.net.raw", containing data for zone example.net,
# to text-format zone file "example.net.text"
#
#   (command)     (format options)   (output file)  (zone origin) (input file)
named-compilezone -f raw -F text -o example.net.text example.net example.net.raw

text to raw:

# convert text format zone file "example.net.text", containing data for zone
# example.net, to raw zone file "example.net.raw"
#
#   (command)     (format options)   (output file) (zone origin)  (input file)
named-compilezone -f text -F raw -o example.net.raw example.net example.net.text
Michael McNally
  • 1,500
  • 9
  • 14
  • Thank you. There are 2 files. 1st file is db-HdPKbJ2m(original not binary) and db.example.com(binary) and i used command like this: `named-compilezone -f raw -F text -o db.example.com db-HdPKbJ2m db.example.com` But This error has been happened. `dns_master_load: example.com: not at top of zone dns_master_load: not at top of zone zone db-HdPKbJ2m/IN: loading from master file db.example.com failed: not at top of zone zone db-HdPKbJ2m/IN: not loaded due to errors.` – user1044942 Mar 18 '13 at 02:23
  • It is possible something on your system corrupted the zone files in some way. My recommendation would be that if the files are not reading correctly I would stop the server on the slave, delete the corrupt zone files (or if you prefer, rename them to move them out of the way), and restart the slave server. It should retransfer the zone contents from the master. – Michael McNally Mar 19 '13 at 01:37
  • Thanks for this enlightenment. FYI it takes over(!) 5(!) minutes(!) to dump an 11 KB zone file of just 628 entries at my side. No, it's neither IO nor CPU bound. (This probably must be called bind magic.) And another interesting question: Why do I need to specify a zone name? Isn't this information already in the file?!? (Well, let's call this a dark bind secret.) PS: With **option `-i none`** it takes a fraction of a second. – Tino Feb 10 '17 at 20:16
12

Or just edit your named.conf and use this Option :

Masterfile-Format Text;

you can do it same in every Zone Option.

VBnoob
  • 121
  • 1
  • 2