Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to monitor my DNS server with Nagios. I understand there's a check_dns plugin but I'm a total Nagios noob and I have no idea how I would go about using the plugin. All I want to do is the equivalent of making sure an nslookup command succeeds. Can someone point me in the right direction?

share|improve this question
up vote 7 down vote accepted

login the nagios server with putty (windows) or slogin in a unix shell. If you login as root, become the nagios user:

# su - nagios [enter]

Go to the /usr/local/nagios/libexec dir (assuming you have installed nagios from source, if you have used a package from your distribution, check the docs of your package):

$ cd /usr/local/nagios/libexec

execute the check_dns plugin with the --help switch. It will give you all the available options:

$./check_dns --help
check_dns v1.4.15 (nagios-plugins 1.4.15)
Copyright (c) 1999 Ethan Galstad <>
Copyright (c) 2000-2008 Nagios Plugin Development Team

This plugin uses the nslookup program to obtain the IP address for the given host/domain query.
An optional DNS server to use may be specified.
If no DNS server is specified, the default server(s) specified in /etc/resolv.conf will be used.

check_dns -H host [-s server] [-a expected-address] [-A] [-t timeout] [-w warn] [-c crit]

 -h, --help
    Print detailed help screen
 -V, --version
    Print version information
 -H, --hostname=HOST
    The name or address you want to query
 -s, --server=HOST
    Optional DNS server you want to use for the lookup
 -a, --expected-address=IP-ADDRESS|HOST
    Optional IP-ADDRESS you expect the DNS server to return. HOST must end with
    a dot (.). This option can be repeated multiple times (Returns OK if any
    value match). If multiple addresses are returned at once, you have to match
    the whole string of addresses separated with commas (sorted alphabetically).
 -A, --expect-authority
    Optionally expect the DNS server to be authoritative for the lookup
 -w, --warning=seconds
    Return warning if elapsed time exceeds value. Default off
 -c, --critical=seconds
    Return critical if elapsed time exceeds value. Default off
 -t, --timeout=INTEGER
    Seconds before connection times out (default: 10)

Send email to if you have questions
regarding use of this software. To submit patches or suggest improvements,
send email to

So, if you want to check that resolves to, yo do this:

./check_dns -H -a
DNS OK: 0.013 seconds response time. returns|time=0.012614s;;;0.000000

As you can see you can also especify which DNS server to query with the -s switch, warning and critical thresholds, etc. Once you're satisfied with the check you run from the cli, you edit the nagios config file where you define the services (probably services.cfg) and apply the check to a given host(group). But that is much better documented in the fine manual you can even read from the web interface that got installed when you installed nagios.

share|improve this answer

You probably already have the command defined in your stock nagios config like so:

define command{
    command_name    check_dns
    command_line    /usr/lib/nagios/plugins/check_dns -H -s $HOSTADDRESS$

Mine is in /etc/nagios/objects/commands.cfg

The most simple case is to define a service that checks the DNS server on the host:

define service{
    use                 generic-service
    host_name           ns1
    service_description DNS
    check_command       check_dns

Note that this assumes:

  • that you have ns1 set up as a host already
  • that you have a template generic service already set up with useful defaults
  • that any other objects that either the host or the template depend on, like time periods and contacts, are already defined

Nagios is a pretty complicated tool, there's no really easy 'quick start'.

share|improve this answer

In order that the command looks for binary check_dns in the right place better to define it using nagios variables (default installation):

define command{
  command_name    check_dns
  command_line    $USER1$/check_dns -H -a -s $HOSTADDRESS$

The above command checks that the server being tested returns the address for hostname

share|improve this answer

Run the plugin with -h and it should give you documentation on how to use it. Normal paramters include the host to test, limits for critical and warning limits. DNS test will likely include what you want to look up.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.