Now that I'm moving my main server, I'm spending some time refining and simplifying some of its setup, and it has now come to the DNS server (bind 9.9.5 in the new setup).
I noticed that in my config, I have a lot of zones defined this way:
zone "123.123.123.123.in-addr.arpa" in {
type master;
file "123.123.123.123";
};
zone "123.123.123.124.in-addr.arpa" in {
type master;
file "123.123.123.124";
};
zone "example.com" in {
type master;
file "example.com";
};
zone "example.net" in {
type master;
file "example.net";
};
// With another ~20 definitions like that
This seems very inefficient to me. Is there a way of automatically loading all files found the directory dictated by the options { directory "/some/folder" }
, and assuming master for each?
No, there is not a way to do this within
named.conf
and its included files. Every zone must be explicitly defined, along with a type and data source at a bare minimum. You can have multiple zones reference the same file if the records they contain should be exact duplicates, but that is the only shortcut for this.Other options can have their defaults set in the global options block (
allow-transfer
,also-notify
, etc.), but you are stuck with defining every zone and the mandatory fields at a bare minimum.For the sake of completeness, I'll mention one exception with newer versions of BIND that I strongly recommend against. You can use the new
rndc addzone
functionality to remotely create a zone on the fly, but what this really does is create an additional configuration file with a hashed name (i.e. randomized characters in the filename) and a.nzf
suffix that BIND "knows" to load. This is very bad from a maintainability standpoint as it violates the principle of least surprise/astonishment; the main configuration file makes no reference to these additional config files and other administrators will have no idea that the contents of these files are being loaded unless they're familiar with the feature. (and very DNS admins are due to its newness)