DNS HOWTO 中譯版 : 維護工作
Previous: 真實領域的例子
Next: Bind version 8

6. 維護工作

維持它的運作.

維持它們的繼續執行之外,對於 named 你還有個維護的任務得要做. 那就是維持 root.cache 檔案的更新.最簡單的方法是使用 dig 程式, 首先不加任何參數執行 dig 程式,你將會取得從你自己伺服器得到的 root.cache. 然後以 dig @rootserver . ns 查問所列出的根伺服器其中之一. 你將會注意到這份輸出看起來非常地像一個 root.cache 檔案,除了一堆額外的數字以外.這些數字不會有什麼妨礙. 把它存放到檔案裡(dig @e.root-servers.net . ns >root.cache.new)並且用它來取代原本舊的 root.cache 檔案.

取代了原先的檔案之後要記得重新啟動 named 程式.

Al Longyear 寄給我這個指令稿,它可以自動執行來更新 named.cache,為它安裝個 crontab 項目然後忘了它. 這個指令稿假設你的電子郵件可以運作而且 `hostmaster' 這個郵件別名有定義.你應該修訂它以便符合你的設定.


#!/bin/sh
#
# Update the nameserver cache information file once per month.
# This is run automatically by a cron entry.
#
(
 echo "To: hostmaster <hostmaster>"
 echo "From: system <root>"
 echo "Subject: Automatic update of the named.boot file"
 echo

 export PATH=/sbin:/usr/sbin:/bin:/usr/bin:
 cd /var/named

 dig @rs.internic.net . ns >root.cache.new

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

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

有些人可能用 ftp 從 Internic 得到 root.cache 檔案. 請不要用 ftp 來更新 root.cache,上面提到的方法更為便利.


DNS HOWTO 中譯版 : 維護工作
Previous: 真實領域的例子
Next: Bind version 8