view · edit · history · print

Using nslookup, dig, and host

nslookup, dig, and host are useful commands that allow you to perform DNS queries, and to test out your DNS configuration.

You can use the nslookup command interactively to enter a shell from which you can change servers, set query options, and debug DNS. You can also use nslookup non-interactively from the command line to issue simple queries. See nslookup(1Mtcp). Also see dig(1Mtcp).

Finally, you can use the host command to provide answers to simple host queries. See host(1Mtcp) for more information.

Using nslookup interactively

1. Enter nslookup at the command line. The nslookup prompt appears.

2. View the current options by entering set all.

3. Change any desired options by entering set option.

4. Issue nslookup commands.

5. Enter exit to leave nslookup.

For a list of sample commands, see ``nslookup interactive commands. For a list of options, see ``nslookup interactive options.

nslookup interactive commands

These sample commands are available from the nslookup shell:

 volga

Return the IP address of volga.

 172.16.118.1

Return the name matching the IP address you enter.

 set querytype=ns

Set the query type to the Name Server record. Future queries of names and IP addresses return the NS record from that host.

 set querytype=a

Restore the query type to the Address record.

 server server

Make server the default server that is queried.

nslookup interactive options

Here are the commonly used options of nslookup. For a complete list, see the manual page for nslookup(1Mtcp).

 [no]recurse

Sets the query type to recursive. When toggled to norecurse, nslookup performs iterative queries.

 querytype=type

Sets the query type to the DNS data type specified. Common types include a (Address), any (any data type), mx (Mail Exchanger), and ns (Name Server).

 retry=n

Resends the query n times before giving up.

 root=root server

Sets the root server to the server you enter.

 timeout=n

The period of time nslookup waits for a response after the query is sent. This period doubles between each retry.

You can save any of these options in a .nslookuprc file in your home directory. The format of this file, which is searched for each time you invoke nslookup, is one set command per line. Here is an example, which sets the query type to address records, the domain to mynet.com, and sets the timeout on requests to 10 seconds:

   set querytype=a
   set domain=mynet.com
   set timeout=10

Querying a single name or address

To issue a simple query from the command line, use one of the following forms of the nslookup command:

 nslookup name

 nslookup IP_address

nslookup should return the desired answer by querying the default server. To query a different server, enter one of the following forms of the command:

 nslookup name server

 nslookup IP_address server

Examples of using the dig command

Obtain the latest list of root domain servers:

 dig . ns

Find out the name servers for a zone:

 dig @server domain ns

Request all records for a zone from an authoritative server:

 dig @server domain axfr

NOTE: This command requires a zone transfer which the server may disallow.

Look up the domain name corresponding to the IP address 172.16.118.1:

 dig -x 172.16.118.1

Examples of using the host command

Use host to find all the host records for a zone:

 host -l domain

Use host to request all the records for a zone:

 host -l -v -t any domain

NOTE: These commands require a zone transfer which the server may disallow.


© 2002 Caldera International, Inc. All rights reserved. http://uw713doc.sco.com/en/NET_tcpip/dnsC.nslook.html

admin · attr · attach · edit · history · print
Page last modified on September 13, 2007, at 08:36 AM