Mantenerlo operativo
C'è un altro compito di manutenzione che dovete fare sui named,
oltre a quello di tenerli operativi. Consiste nel mantenere aggiornato
il file root.hints. Il modo più semplice è usare dig, fate
partire dig senza argomenti, otterrete root.hints in accordo col
quello che c'è sul vostro server. Poi fate una richiesta a uno dei root
server elencati con dig @rootserver. Vedrete che l'output
somiglierà terribilmente al file root.hints. Salvatelo in un file
(dig @e.root-servers.net . ns >root.hints.new) e rimpiazzate il
vecchio root.hints con questo.
Ricordate di fare reload di named dopo aver rimpiazzato il cache file.
Questo script mi è stato mandato da Al Longyear, può essere fatto
partire automaticamente per aggiornare root.hints, impostate una
riga nel crontab che lo faccia partire una volta al mese e
dimenticatelo. Lo script assume che il vostro sistema di posta funzioni
e che l'alias di posta `hostmaster' sia definito. Dovrete editarlo
perché si conformi alle vostre esigenze.
#!/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 root.hints file"
echo
PATH=/sbin:/usr/sbin:/bin:/usr/bin:
export PATH
cd /var/named
# Are we online? Ping a server at your ISP
case `ping -qnc 1 some.machine.net` in
*'100% packet loss'*)
echo "The network is DOWN. root.hints NOT updated"
echo
exit 0
;;
esac
dig @e.root-servers.net . ns >root.hints.new 2>&1
case `cat root.hints.new` in
*NOERROR*)
# It worked
:;;
*)
echo "The root.hints file update has FAILED."
echo "This is the dig output reported:"
echo
cat root.hints.new
exit 0
;;
esac
echo "The root.hints file has been updated to contain the following
information:"
echo
cat root.hints.new
chown root.root root.hints.new
chmod 444 root.hints.new
rm -f root.hints.old
mv root.hints root.hints.old
mv root.hints.new root.hints
ndc restart
echo
echo "The nameserver has been restarted to ensure that the update is complete."
echo "The previous root.hints file is now called
/var/named/root.hints.old."
) 2>&1 | /usr/lib/sendmail -t
exit 0
Qualcuno di voi potrebbe aver notato che il file root.hints
è disponibile anche in ftp da Internic. Per favore, non usate ftp per
aggiornare root.hints, il metodo sopra descritto è molto più
amichevole per la rete, e per Internic.