DNS HOWTO : Maintenance
Previous: /etc/namedb/206.6.177
Next: Converting from version 4 to version 8

6. Maintenance

Keeping it working.

There is one maintenance task you have to do on nameds, other than keeping them running. That's keeping the root.hints file updated. The easiest way is using dig, first run dig with no arguments, you will get the root.hints according to your own server. Then ask one of the listed root servers with dig @rootserver. You will note that the output looks terribly like a root.hints file. Save it to a file (dig @e.root-servers.net . ns >root.hints.new) and replace the old root.hints with it.

Remember to reload named after replacing the cache file.

Al Longyear sent me this script, that can be run automatically to update root.hints, install a crontab entry to run it once a month and forget it. The script assumes you have mail working and that the mail-alias `hostmaster' is defined. You must hack it to suit your setup.


#!/bin/sh
#
# Update the nameserver cache information file once per month.
# This is run automatically by a cron entry.
#
# Original by Al Longyear
# Updated for bind 8 by Nicolai Langfeldt
# Miscelanious error-conditions reported by David A. Ranch
# Ping test suggested by Martin Foster
#
(
 echo "To: hostmaster <hostmaster>"
 echo "From: system <root>"
 echo "Subject: Automatic update of the named.root file"
 echo

 PATH=/sbin:/usr/sbin:/bin:/usr/bin:
 export PATH
 cd /etc/namedb

 # Are we online?  Ping a server at your ISP
 case `ping -qnc some.machine.net` in
   *'100% packet loss'*)
	echo "The network is DOWN. named.root NOT updated"
	echo
	exit 0
	;;
 esac

 dig @rs.internic.net . ns >named.hints.new 2>&1

 case `cat named.root.new` in
   *NOERROR*)
	# It worked
	:;;
   *)
	echo "The named.root file update has FAILED."
   	echo "This is the dig output reported:"
   	echo
   	cat named.root.new
        exit 0
	;;
 esac

 echo "The named.root file has been updated to contain the following   
information:"
 echo
 cat named.root.new

 chown named.root named.root.new
 chmod 444 named.root.new
 rm -f named.root.old
 mv named.root named.root.old
 mv named.root.new named.root
 ndc restart
 echo
 echo "The nameserver has been restarted to ensure that the update is complete."
 echo "The previous named.root file is now called   
/etc/namedb/named.root.old."
) 2>&1 | /usr/lib/sendmail -t
exit 0

Some of you might have picked up that the root.hints file is also available by ftp from Internic. Please don't use ftp to update root.hints, the above method is much more friendly to the net, and Internic.


DNS HOWTO : Maintenance
Previous: /etc/namedb/206.6.177
Next: Converting from version 4 to version 8