Monitoring DNS servers


I recently started supporting several DNS servers running BIND 9. To ensure that these server are up and operational at all times, I wrote a small shell script named dns-check to test the operational state of each server. The script takes a file as an argument, and each line in the file contains the IP address of a DNS server (names will also work), a name to resolve, and the record type that should be requested. If the script is unable to resolve the name for one reason or another (any return code > 0 is a failure), the script will log a message to syslog, and send E-mail to the address listed in the $ADMIN variable, or an address passed to the “-e” option. Here is sample run:

$ cat dns-check-sites
ns1.fooby.net mail.fooby.net A ns2.fooby.net mail.fooby.net A

$ dns-check -e dns-admin@prefetch.net -f dns-check-sites

The script is nothing special, but might be useful to folks running DNS servers.

This article was posted by Matty on 2006-08-20 14:43:00 -0400 -0400