9.4 How to Use nslookup

If your site is connected to the Internet, you can use the nslookup(1) program to interactively find MX and other records. To run nslookup, just type its name:

% nslookup

Note that you might have to give the full pathname. Under SunOS, nslookup lives in the /usr/etc directory; under Ultrix, in /usr/ucb; under HP-UX, in /usr/bin; and under Solaris and FreeBSD, in the /usr/sbin directory.

Once nslookup is running, it prints the name of your default name server and the IP address for that machine, then a > character as a prompt, and awaits input:

Server:  Your.Main.Server


To tell nslookup to look up only MX records,[12] use the set command:

[12] Beginning with V8.7 sendmail, you can also use the /mx command in -bt rule-testing mode (Section 8.5.2) to look up MX records.

> set type=mx

Now look up some real hosts and domains. First look up the domain sendmail.org by entering its name at the prompt:

> sendmail.org.

Note the trailing dot that tells nslookup(1) that the local, default domain should not be appended prior to the lookup. The output produced by this lookup looks like this:

> sendmail.org.
Server:  Your.Main.Server

sendmail.org    preference = 10, mail exchanger = smtp.neophilic.com
sendmail.org    preference = 20, mail exchanger = smtp.gshapiro.net
sendmail.org    preference = 100, mail exchanger = playground.sun.com
smtp.neophilic.com      internet address =
smtp.gshapiro.net       internet address =
playground.sun.com      internet address =

The first two lines again show the name and IP address of the local DNS server. The next three lines show that the domain sendmail.org has three MX records. Mail addressed to that domain is sent to the machine with the lowest preference (cost), which happens to be smtp.neophilic.com.[13] If that machine is down (or not accepting mail), the message is sent to the machine with the next higher cost, smtp.gshapiro.net. The last three lines show the IP addresses (A records) for those machines.

[13] Note that case is not significant in domain names; all of the following are the same: org, OrG, ORG.

The nslookup(1) program is a useful tool for performing all the same lookups that are done by sendmail. Each type of lookup corresponds to a set type. A list of some available nslookup(1) types is shown in Table 9-1.

Table 9-1. Some nslookup types




IPv4 address


IPv6 address


All the currently cached records


Canonical name for an alias


Host CPU and operating system type (seldom used)


Mail exchanger records


Name server record


Site of Authority record

To exit nslookup(1), just type exit (or Ctrl-D if that fails).

    Part I: Build and Install
    Part II: Administration
    Part III: The Configuration File