21.5. Secondary slave name Server

The purpose of a slave name server is to share the load with the master server, or handle the entire load if the master server is down. A slave name server loads its data over the network from another name server usually the master name server, but it can load from another slave name server too. This process is called a zone transfer. Necessary files to setup a secondary slave name server are:

  1. named.conf

  2. db.127.0.0

  3. db.cache

  4. named script

To configure the /etc/named.conf file for a slave name server, use this configuration for the server on your network that acts as a slave name server. You must modify the named.conf file on the slave name server host. Change every occurrence of primary to secondary except for 0.0.127.in-addr.arpa and add a masters line with the IP address of the master server as shown below.

Create the named.conf file (touch /etc/named.conf) and add:

   options {
   directory "/var/named";
   fetch-glue no;
   recursion no;
   allow-query { 208.164.186/24; 127.0.0/8; };
   allow-transfer { 208.164.186.1; };
   transfer-format many-answers;
   };

   // These files are not specific to any zone
   zone "." in {
   type hint;
   file "db.cache";
   };

   zone "0.0.127.in-addr.arpa" in {
   type master;
   file "db.127.0.0";
   };

   // These are our slave zone files
   zone "openna.com" in {
   type slave;
   file "db.openna";
   masters { 208.164.186.1; };
   };

   zone "186.164.208.in-addr.arpa" in {
   type slave;
   file "db.208.164.186";
   masters { 208.164.186.1; };
   };
   
This tells the name server that it is a slave for the zone openna.com and should track the version of this zone that is being kept on the host 208.164.186.1.

A slave name server doesn't need to retrieve all of its database (db) files over the network because these db files db.127.0.0 and db.cache are the same as on a primary master, so you can keep a local copy of these files on the slave name server.

  1. Copy the db.127.0.0file from master name server to slave name server.

  2. Copy the db.cache file from master name server to slave name server.

21.5.1. /etc/rc.d/init.d/named script

Configure your /etc/rc.d/init.d/named script file to start and stop the BIND/DNS daemon on your Server. This configuration script file can by used for all type of name server caching, master or slave.

Create the named script file touch /etc/rc.d/init.d/named and add:

   #!/bin/sh
   #
   # named           This shell script takes care of starting and stopping
   #                 named (BIND DNS server).
   #
   # chkconfig: - 55 45
   # description: named (BIND) is a Domain Name Server (DNS) \
   # that is used to resolve host names to IP addresses.
   # probe: true

   # Source function library.
   . /etc/rc.d/init.d/functions

   # Source networking configuration.
   . /etc/sysconfig/network

   # Check that networking is up.
   [ ${NETWORKING} = "no" ] && exit 0

   [ -f /usr/sbin/named ] || exit 0

   [ -f /etc/named.conf ] || exit 0

   RETVAL=0

   # See how we were called.
   case "$1" in
   start)
   # Start daemons.
   echo -n "Starting named: "
   daemon named
   RETVAL=$?
   [ $RETVAL -eq 0 ] && touch /var/lock/subsys/named
   echo
   ;;
   stop)
   # Stop daemons.
   echo -n "Shutting down named: "
   killproc named
   RETVAL=$?
   [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/named
   echo
   ;;
   status)
   /usr/sbin/ndc status
   exit $?
   ;;
   restart)
   $0 stop
   $0 start
   ;;
   reload)
   /usr/sbin/ndc reload
   exit $?
   ;; 
   probe)
   # named knows how to reload intelligently; we don't want linuxconf
   # to offer to restart every time
   /usr/sbin/ndc reload >/dev/null 2>&1 || echo start
   exit 0
   ;;

   *)
   echo "Usage: named {start|stop|status|restart}"
   exit 1
   esac

   exit $RETVAL
   

Now, make this script executable and change its default permissions:

   [root@deep]# chmod 700  /etc/rc.d/init.d/named
   
Create the symbolic rc.d links for BIND/DNS with the command:

   [root@deep]# chkconfig --add named
   

The BIND/DNS script will not automatically start the named daemon when you reboot the server. You can change its default by executing the following command:

   [root@deep]# chkconfig --level 345 named on
   
Start your DNS Server manually with the following command:

   [root@deep]# /etc/rc.d/init.d/named start
   

   Starting named:                                            [  OK  ]