#!/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 " echo "From: system " # Is named up? Check the status of named. case `rndc status 2>&1` in *refused*) echo "named is DOWN. db.root 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 /etc/bind 2>/dev/null || { echo "Subject: Cannot cd to /etc/bind, error $?" echo echo "The subject says it all" exit 1 } # Are we online? Ping a server at your ISP case `ping -qnc 1 212.100.160.51 2>&1` in *'100% packet loss'*) echo "Subject: db.root NOT updated. The network is DOWN." echo echo "The subject says it all" exit 1 ;; esac dig @e.root-servers.net . ns >db.root.new 2> errors case `cat db.root.new` in *NOERROR*) # It worked :;; *) echo "Subject: The db.root file update has FAILED." echo echo "The db.root update has failed" echo "This is the dig output reported:" echo cat db.root.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 db.root.new chown root.root db.root.new chmod 444 db.root.new rm -f db.root.old errors mv db.root db.root.old mv db.root.new db.root /etc/init.d/bind9 restart echo echo "The nameserver has been restarted to ensure that the update is complete." echo "The previous root.hints file is now called /etc/bind/db.root.old.") 2>&1 | /usr/lib/sendmail -t exit 0