One way to organize your zone data
files is to store them in separate directories. If your name server
is a primary master for several sites' zones (both forward- and
reverse-mapping), you could store each site's zone data files
in its own directory. Another arrangement might be to store all the
primary master zones' data files in one directory and all the
backup zone data files in another. Let's look at what the BIND
4 configuration file might look like if you chose to split up your
primary master and slave zones:
directory /var/named
;
; These files are not specific to any zone
;
cache . db.cache
primary 0.0.127.in-addr.arpa db.127.0.0
;
; These are our primary zone files
;
primary movie.edu primary/db.movie.edu
primary 249.249.192.in-addr.arpa primary/db.192.249.249
primary 253.253.192.in-addr.arpa primary/db.192.253.253
;
; These are our slave zone files
;
secondary ora.com 198.112.208.25 slave/bak.ora.com
secondary 208.112.198.in-addr.arpa 198.112.208.25 slave/bak.198.112.208
Here's the same configuration file in BIND 8 format:
options { directory "/var/named"; };
//
// These files are not specific to any zone
//
zone "." {
type hint;
file "db.cache";
};
zone "0.0.127.in-addr.arpa" {
type master;
file "db.127.0.0";
};
//
// These are our primary zone files
//
zone "movie.edu" {
type master;
file "primary/db.movie.edu";
};
zone "249.249.192.in-addr.arpa" {
type master;
file "primary/db.192.249.249";
};
zone "253.253.192.in-addr.arpa" {
type master;
file "primary/db.192.253.253";
};
//
// These are our slave zone files
//
zone "ora.com" {
type slave;
file "slave/bak.ora.com";
masters { 198.112.208.25; };
};
zone "208.112.192.in-addr.arpa" {
type slave;
file "slave/bak.198.112.208";
masters { 198.112.208.25; };
};
Another variation on this division is to break the configuration file
into three files: the main file, a file that contains all the
primary entries, and a file that contains all
the secondary entries. Here's what the
main BIND 4 configuration file might look like:
directory /var/named
;
; These files are not specific to any zone
;
cache . db.cache
primary 0.0.127.in-addr.arpa db.127.0.0
;
include named.boot.primary
include named.boot.slave
Here is named.boot.primary (BIND 4):
;
; These are our primary zone files
;
primary movie.edu primary/db.movie.edu
primary 249.249.192.in-addr.arpa primary/db.192.249.249
primary 253.253.192.in-addr.arpa primary/db.192.253.253
Here is named.boot.slave (BIND 4):
;
; These are our slave zone files
;
secondary ora.com 198.112.208.25 slave/bak.ora.com
secondary 208.112.198.in-addr.arpa 198.112.208.25 slave/bak.198.112.208
Here are the same files in BIND 8 or 9 format:
options { directory "/var/named"; };
//
// These files are not specific to any zone
//
zone "." {
type hint;
file "db.cache";
};
zone "0.0.127.in-addr.arpa" {
type master;
file "db.127.0.0";
};
include "named.conf.primary";
include "named.conf.slave";
Here is named.conf.primary (BIND 8 or 9):
//
// These are our primary zone files
//
zone "movie.edu" {
type master;
file "primary/db.movie.edu";
};
zone "249.249.192.in-addr.arpa" {
type master;
file "primary/db.192.249.249";
};
zone "253.253.192.in-addr.arpa" {
type master;
file "primary/db.192.253.253";
};
Here is named.conf.slave (BIND 8 or 9):
//
// These are our slave zone files
//
zone "ora.com" {
type slave;
file "slave/bak.ora.com";
masters { 198.112.208.25; };
};
zone "208.112.192.in-addr.arpa" {
type slave;
file "slave/bak.198.112.208";
masters { 198.112.208.25; };
};
You might think the organization would be better if you put the
configuration file with the primary directives
into the primary subdirectory by adding a new
directory directive to change to this directory,
and remove the primary/ from each of the
filenames since the name server is now running in that directory.
Then you could make comparable changes in the configuration file with
the secondary lines. Unfortunately, that
doesn't work. BIND 8 and 9 name servers allow you to define
only a single working directory. BIND 4 name servers let you redefine
the working directory with multiple directory
directives, but that's more of an oversight than a feature.
Things get rather confused when the name server keeps switching
around to different directories -- backup zone data files end up
in the last directory the name server changed to, and when the name
server is reloaded, it may not be able to find the main configuration
file if it isn't left in the directory where it started (if the
configuration file is specified with a relative pathname).