8. 유지

작동이 되게 유지하라.

named의 기능이 유지되게 해야 하며 그것이 지속적으로 구동되게 해야 한다. 그럴려면 root.hints를 업데이트 해야 한다. 가장 손쉬운 방법은 dig를 이용하는 것이다. 먼저 어떤 인수도 없이 dig 를 구동시키면 자신의 서버에 해당하는 root.hints를 얻게 될 것이다. 그리고 나서는 dig @rootserver로 나열된 루트서버중 하나에 질의를 한다. root.hints 파일을 나타내는 출력결과를 주시해야 한다. 파일을 저장하고(dig @e.root-servers.net . ns>root.hints.new) root.hints 파일을 교체하면 된다.

항상 캐쉬파일을 교체하고 나면 named를 재구동 해야 한다는 사실을 염두해 두길.

Al Longyear씨가 자동적으로 root.hints를 갱신할 수 있는 스크립트를 제공해 주었다. crontab에 저장하고 한달에 한번씩 돌아가게 설정하면 그뒤에는 신경쓰지 않아도 된다. 이 스크립트는 여러분의 메일이 작동하고 mail-alias '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
# named up-test suggested by Erik Bryer.
#
(
 echo "To: hostmaster <hostmaster>"
 echo "From: system <root>"

 # Is named up? Check the status of named.
 case `ndc status 2>&1` in
    *'cannot connect to command channel'*)
        echo "named is DOWN. root.hints was NOT updated"
        echo
        exit 0
        ;;
 esac

 PATH=/sbin:/usr/sbin:/bin:/usr/bin:
 export PATH
 # NOTE: /var/named must be writable only by trusted users or this script 
 # will cause root compromise/denial of service opportunities.
 cd /var/named 2>/dev/null || {
    echo "Subject: Cannot cd to /var/named, error $?"
    echo
    echo "The subject says it all"
    exit 1
 }

 # Are we online?  Ping a server at your ISP
 case `ping -qnc 1 some.machine.net 2>&1` in
   *'100% packet loss'*)
        echo "Subject: root.hints NOT updated.  The network is DOWN."
	echo
	echo "The subject says it all"
	exit 1
	;;
 esac

 dig @e.root-servers.net . ns >root.hints.new 2> errors

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

 echo "Subject: The root.hints file has been updated"
 echo
 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 errors
 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 파일을 인터닉의 ftp로부터 가져오는 것이 유용하다고 한다. ftp를 사용하지 말고 위의 방법으로 root.hints 를 업데이트 하기를. 위의 방법이 더 net상에서, 그리고 internic 에도 좋은 것이다.