Bind 9

The Domain Name System is basically a database of host information. DNS distributed database is indexed by domain names. Each domain name is essentially just a path in a large inverted tree, called the domain name space.

Configuration file

The named configuration file is located at /etc/named.conf.

Working directory

The working directory is normally located at /var/named , however there is a option in the configuration file which can change this:

  options {
          directory "/var/named/";
          dump-file "/var/named/dbdump";
          forwarders { 192.168.0.10; };
        };

Zone data files

Zone data files (resource files) are located by the file option within the zone section

  zone "movie.edu" in {
                      type master;
                      file "db.movie";
                    };

Process

The DNS process is called named

            named   2334   1   0 21:29 ?    00:00:00 /usr/sbin/named -u named

Setting up RNDC

To setup rndc between master and a slave server you must add the following to the named.conf file on both primary and slave servers:

 

key "dnsadmin" {
                 algorithm hmac-md5;
                 secret "QAGUxh2F0sYIL26nCgF7cgLjV8ShtxNR47LmpHS3XyE=";
               };

server 192.168.0.8 {
                     keys {"dnsadmin"; };
                   };

controls {
           inet * allow { 127.0.0.1; 192.168.0.8; } keys {"dnsadmin";};
         };

All communication with servers is authenticated with digital signatures that rely on a shared secret, this secret key is supplied via the configuration file normally /etc/rndc.conf but also can be supplied via /etc/named.conf as above. To following control options can be used to access other DNS servers.

Reload configuration file and zones Reload
Reload the given zone Reload
Reload config file and new zones only Reconfig
write server stats Stats
toggle query logging Querylog
dump the servers caches Dumpdb
increment tracing by one Trace
increase tracing by level Trace
set the tracing level to 0 Notrace
flush the servers cache Flush
display the servers status Status

Examples:

  # rndc reload
# rndc reload movie.edu.
# rndc –s <server> reload movie.edu
# rndc trace 3

Note: use the –s option to select a bind server (master or slave)

Logging

To log bind information use the below in /etc/named.conf

 

logging {
          channel my_file {
                            file "/var/named/log.msgs" versions 3 size 3m;
                            severity info;
                          };

          category default { my_file; };
        };

Logging is a two step approach, first you create a channel to log to, then select what to log to that channel. In the example above a channel “my_file” will log to a file called “/var/named/log/msgs” it will rotate 3 versions of a maximum size of 3Mb. The category option then lets named know what to log, see below for more logging options:

The catch-all category general
Approval and denial requests security
Messages that named was unable to determine unmatched
Dynamic updates update
Queries queries

$ORGIN directive

The $ORGIN directive allows you setup sub-domains within a domain see below for an example:

 

$ORIGIN comedy.movie.edu.

mash       IN A     192.249.249.30
wins       IN A     192.249.249.31

This sets up a comedy.movie.edu sub-domain with the movie.edu domain. This will be located within the movie.edu zone file.

Serial Number

One of the most common mistakes when updating a zone is forgetting to increase the serial number of that zone.  

 

@ IN SOA linux1 root.linux1 (

6        ; Serial
10800    ; Refresh after 3 hours
3600     ; Retry after 1 hour
604800   ; Expire after 1 week
86400)   ; Minimum TTL of 1 day

);

When a zone file has been updated to inform the slave servers that the zone has been updated increase the serial number and then reload the zone.

To obtain the serial number of a zone use the following

            dig @<name_server> <zone> soa

named.conf file

 

## named.custom - custom configuration for bind
#
# Any changes not currently supported by system-config-bind should be put
# in this file.
#
options {
        directory "/var/named/";
        dump-file "/var/named/dbdump";
        #forwarders { 192.168.0.10; };
};

key "dnsadmin" {
        algorithm hmac-md5;
        secret "QAGUxh2F0sYIL26nCgF7cgLjV8ShtxNR47LmpHS3XyE=";
};

server 192.168.0.8 {
        keys {"dnsadmin"; };
};

controls {
        inet * allow { 127.0.0.1; 192.168.0.8; } keys {"dnsadmin";};
};

logging {
        channel my_file {
                          file "/var/named/log.msgs" versions 3 size 3m;
                          severity info;
                        };
        category default { my_file; };
};

# Cache   file
zone "." {
        type hint;
        file   "db.cache";
};

zone "movie.edu" in {
        type master;
        file "db.movie";
};

zone "249.249.192.in-addr.arpa" in {
        type master;
        file "db.192.249.249";
};

zone "253.253.192.in-addr.arpa" in {
        type master;
        file "db.192.253.253";
};

Resource records ( db.movie domain )

 

@ IN SOA linux1 root.linux1 (
                        6        ; Serial
                        10800    ; Refresh after 3 hours
                        3600     ; Retry after 1 hour
                        604800   ; Expire after 1 week
                        86400 ) ; Minimum TTL of 1 day
;

; Name servers
;
                IN NS linux1
;

; Addresses for the canonical names
;
localhost       IN A     127.0.0.1
robocop         IN A     192.249.249.2
terminator      IN A     192.249.249.3
diehard         IN A     192.249.249.4
misery          IN A     192.249.249.5
aliens          IN A     192.249.249.6
nightstalker    IN A     192.249.249.7
solaris         IN A     192.249.249.8
www             IN A     192.249.249.20
                IN A     192.249.249.21
                IN A     192.249.249.22
;

; Aliases
;
arnie           IN CNAME         terminator
dh              IN CNAME         diehard
robo            IN CNAME         robocop
;

; Interfaces specific names
;
wh249            IN A     192.249.249.5
wh253            IN A     192.253.253.5
;

; This creates a subdomain with the movie.edu domain
$ORIGIN comedy.movie.edu.
mash             IN A     192.249.249.30
twins            IN A     192.249.249.31

db.192.249.249
@ IN SOA linux1.movie.edu. root.linux1.movie.edu. (
                                5        ; Serial
                                10800   ; Refresh after 3 hours
                                3600     ; Retry after 1 hour
                                604800   ; Expire after 1 week
                                86400)   ; Minimum TTL of 1 day
;
; Name servers
;
        IN NS    linux1.movie.edu.
;

; Addresses point to canonical name
;
1        IN PTR   wormhole.movie.edu.
2        IN PTR   robocop.movie.edu.
3        IN PTR   terminator.movie.edu.
4        IN PTR   diehard.movie.edu.
5        IN PTR   misery.movie.edu.
6        IN PTR   aliens.movie.edu.
7        IN PTR   nightstalker.movie.edu.
8        IN PTR   solaris.movie.edu.
30       IN PTR   mash.comedy.movie.edu.
31       IN PTR   twins.comedy.movie.edu.