I l@ve RuBoard Previous Section Next Section

5.9 Restarting a Name Server Automatically If It Dies

5.9.1 Problem

You want a name server to restart automatically if it dies.

5.9.2 Solution

Use the nanny.pl Perl script included in the BIND 9 distribution. After you've unpacked the BIND 9 distribution, you'll find nanny.pl in contrib/nanny/nanny.pl.

nanny.pl runs as a daemon, so just modify the variables at the top of the script as needed and then start it. You may also want to configure your host to start nanny.pl at boot time.

There are four variables you may need to customize:

$pid_file_location = '/var/run/named.pid';
$nameserver_location = 'localhost';
$dig_program = 'dig';
$named_program =  'named';

For example, if you're starting named with one or more command-line options, change $named_program accordingly, like so:

$named_program = 'named -t /etc/namedb -u bind';

5.9.3 Discussion

nanny.pl checks every 30 seconds to see if the named process exists using kill -0 against its process ID, and by querying the local name server with dig. If either test fails, the script restarts the name server.

There's nothing specific to BIND 9 in nanny.pl, so you can use it with BIND 8 name servers, too.

5.9.4 See Also

Section 1.19, for starting the name server from the command line.

    I l@ve RuBoard Previous Section Next Section