動作を維持するために
named には、ただ走らせる以外にも一つ保守作業があります。
root.hints ファイルを最新の状態に保つ作業です。
一番簡単なのは dig を使うやり方です。まず引き数なしで dig を動かすと、
現在サーバで使っている root.hints の内容が表示されます。
次にリストされているルートサーバのいずれかに対して dig @rootserver
のように問い合わせを行います。
出力結果は root.hints の内容にとっても似ていることでしょう。
この結果を dig @e.root-servers.net . ns > root.cache.new
のように保存して、古い root.hints と置き換えます。
キャッシュファイルを入れ替えた後には named の再実行をお忘れなく。
Al Longyear がスクリプトを送ってくれました。自動的に
root.hints を更新してくれるものです。
これを月に一度起動する crontab のエントリをインストールすれば、
後は全部おまかせです。スクリプトでは、メールがちゃんと動作していて、
メールエイリアスとして
`hostmaster' が定義されていることを前提としています。
あなたの設定にあわせてハックする必要があります。
#!/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
root.hints は Internic から ftp でも入手できる、
と言うことをすでにご存じの方もいるかもしれません。
ですが root.hints の更新に ftp は使わないようにしてください。
上記の方法のほうが、ずっと「ネット (と Internic) に優しい」のです。