nslookup - query name servers interactively
nslookup [-option ...] host-to-find [server]
nslookup [-option ...] [- [server]]
nslookup is a program to query Internet domain name servers. nslookup
has been extended to follow the configured name resolution algorithm
of the host and to query NIS, as well as, DNS and host tables.
Both an interactive and non-interactive mode are available with
nslookup. Interactive mode allows the user to query a name server for
information about various hosts and domains, or print a list of hosts
in the domain. Non-interactive mode is used to query a name server
for information about one host or domain.
By default, nslookup accesses name services for name and address
resolution based on the policy information obtained from the switch
configuration file /etc/nsswitch.conf. When the policy is set to use
NIS or /etc/hosts first, or when DNS is first but unavailable, then
nslookup will only provide a limited command set (a help command while
in this situation will show what actions are possible when querying
NIS or /etc/hosts). To override the switch policy and query DNS
servers directly, the server command can be used to specify a
nameserver. This same overriding of the switch policy can also be done
by providing a nameserver as the second argument on the command line.
In this case, nslookup will ignore the switch policy and directly
query nameservers, until a reset command is issued. Whenever an action
is taken that causes the switch policy to be overridden, a warning
message is displayed.
Note, NIS+ is not supported by nslookup. If the hosts source nisplus
is found in the /etc/nsswitch.conf file. It will be ignored.
Interactive mode is entered in the following cases:
+ No arguments are given.
+ The first argument is a hyphen (-). The optional second
argument is a host name or Internet (IP) address of a name
Non-interactive mode is used when the name of the host to be looked up
is given as the first argument. The optional second argument is a
host name or Internet address of a name server.
Hewlett-Packard Company - 1 - HP-UX Release 11i: November 2000
Options listed under the set command below can be specified one per
line in the .nslookuprc file in the user's home directory.
Alternatively, these options may be specified on the command line by
prefixing them with a hyphen and they must precede other command line
arguments. For example, to change the default query type to host
information, and the initial timeout to 10 seconds, type:
nslookup -query=hinfo -timeout=10
The command line option -swdebug may be used to debug syntactic errors
in the switch configuration file. This option turns on tracing during
initialization, causing the switch module to print out a trace of the
scan and parse actions on the "hosts" entry (see nsswitch.conf(4)) in
the /etc/nsswitch.conf file.
Commands can be interrupted at any time by using the interrupt
character. To exit, type a Ctrl-D (EOF) or type exit. To treat a
built-in command as a host name, precede it with an escape character
(\). When using NIS or the host table, only host names and Internet
addresses are allowed as commands. An unrecognized command is
interpreted as a host name.
host [server] Look up information for host using the current default
server or using server if specified. If host is an
Internet address and the query type is A or PTR, the
name of the host is returned. If host is a name and
does not have a trailing period, one or more domains
are appended to the name (this behavior depends on the
state of the set options domain, srchlist, defname, and
search). Answers from a name server's cache are
lserver domain Change the default server to domain. lserver uses the
initial server to look up information about domain
while server uses the current default server. When
server is used while the current name service being
pointed to is either NIS or /etc/hosts, then the switch
policy will be overridden until a reset is issued.
root Changes the default server to the server for the root
of the domain name space. Currently, the host
ns.nic.ddn.mil is used (this command is a synonym for
lserverns.nic.ddn.mil). The name of the root server
can be changed with the set root command.
policy Prints out the policy read from the switch
configuration file. The number of name services
specified in the file are shown, as well as the order
and criteria on how the name services are to be used.
Hewlett-Packard Company - 2 - HP-UX Release 11i: November 2000
The four statuses of the criteria are represented by
the four positions within the square brackets. The
order of the statuses are: SUCCESS, NOTFOUND, UNAVAIL
and TRYAGAIN. The two actions of the criteria are
represented by the two possible letters used in the
four status positions: R for return and C for continue.
However, if no criteria is specified between two
sources, then the default actions are assigned to the
finger [name] [>>>> filename]
finger [name] [>>>>>>>> filename]
Connects with the finger server on the current host.
The current host is defined when a previous lookup for
a host was successful and returned address information
(see the set querytype=A command). name is optional.
>>>> and >>>>>>>> can be used to redirect output in the usual
ls [option] domain [>>>> filename]
ls [option] domain [>>>>>>>> filename]
List the information available for domain, optionally
creating or appending to filename. The default output
contains host names and their Internet addresses.
option can be one of the following:
-t querytype lists all records of the specified
type (see querytype below).
-a lists aliases of hosts in the
domain (synonym for -t CNAME).
-d lists all records for the domain
(synonym for -t ANY).
-h lists CPU and operating system
information for the domain (synonym
for -t HINFO).
-s lists well-known services of hosts
in the domain (synonym for -t WKS).
When output is directed to a file, # characters are
printed for every 50 records received from the server.
view filename Sorts and lists the output of previous ls command(s)
using more (see more(1)).
Hewlett-Packard Company - 3 - HP-UX Release 11i: November 2000
? Prints a brief summary of commands.
exit Exits the program.
reset Returns to the use of the configured name service
switch policy and resets to use the original
This command is used to change state information that
affects the lookups. Valid keywords are:
all Prints the current values of the
various options to set.
Information about the current
default server and host is also
cl[ass]=value Change the query class to one of:
IN the Internet class.
CHAOS the Chaos class.
HESIOD the MIT Athena
ANY wildcard (any of the
The class specifies the protocol
group of the information. (Default
[no]deb[ug] Turn debugging mode on. More
information is printed about the
packet sent to the server and the
resulting answer. (Default =
[no]d2 Turn exhaustive debugging mode on.
Essentially all fields of every
packet are printed. (Default =
[no]def[name] If set, append the default domain
name to a single-component lookup
request (i.e., one that does not
contain a period character).
(Default = defname)
Hewlett-Packard Company - 4 - HP-UX Release 11i: November 2000
do[main]=name Change the default domain name to
name. The default domain name is
appended to a lookup request,
depending on the state of the
defname and search options. The
domain search list contains the
parents of the default domain if it
has at least two components in its
name. For example, if the default
domain is CC.Berkeley.EDU, the
search list is CC.Berkeley.EDU and
Berkeley.EDU. Use the set srchlist
command to specify a different
list. Use the set all command to
display the list. (Default = value
from hostname, /etc/resolv.conf or
[no]ig[nore] Ignore truncation errors. (Default
ty[pe]=value Change the type of information
returned from a query to one of:
A Host's Internet
ANY All types of data
CNAME Canonical name for
GID Group ID
HINFO Host CPU and
MB Mailbox domain
MG Mail group member
MINFO Mailbox or mail
MR Mail rename domain
Hewlett-Packard Company - 5 - HP-UX Release 11i: November 2000
MX Mail exchanger
NS Name server for
the named zone
PTR Host name if the
query is an
pointer to other
SOA Start of authority
TXT Text information
UID User ID
UINFO User information
WKS Well-known service
po[rt]=value Change the default TCP/UDP name
server port to value. (Default =
[no]rec[urse] Tell the name server to query other
servers if it does not have the
information. (Default = recurse)
ret[ry]=number Set the number of retries to
number. When a reply to a request
is not received within a certain
amount of time (changed with set
timeout), the timeout period is
doubled and the request is resent.
The retry value controls how many
times a request is resent before
giving up. (Default = 4)
ro[ot]=host Change the name of the root server
to host. This affects the root
command. (Default =
[no]sea[rch] If the lookup request contains at
least one period but doesn't end
with a trailing period, append the
domain names in the domain search
Hewlett-Packard Company - 6 - HP-UX Release 11i: November 2000
list to the request until an answer
is received. See hostname(5).
(Default = search)
Change the default domain name to
name1 and the domain search list to
name1, name2, etc. A maximum of 6
names separated by slashes (/) can
be specified. For example,
sets the domain to lcs.MIT.EDU and
the search list to the three names.
This command overrides the default
domain name and search list of the
set domain command. Use the set
all command to display the list.
(Default = value based on hostname,
/etc/resolv.conf or LOCALDOMAIN)
[no]swtr[ace] When set, this flag causes nslookup
to print out information about the
sources used for resolving a name
or an address lookup. This flag
traces the behavior generated by
the switch policy. (Default =
Change the initial timeout interval
for waiting for a reply to number
seconds. Each retry doubles the
timeout period. (Default = 5
[no]v[c] Always use a virtual circuit when
sending requests to the server.
(Default = novc)
If the lookup request was not successful, an error message is printed.
Possible errors are:
The server did not respond to a request after a certain
amount of time (changed with set timeout=value) and a
certain number of retries (changed with set retry=value).
Hewlett-Packard Company - 7 - HP-UX Release 11i: November 2000
No response from server
No name server is running on the server machine.
The server does not have resource records of the current
query type for the host, although the host name is valid.
The query type is specified with the set querytype command.
The host or domain name does not exist.
Network is unreachable
The connection to the name server could not be made at the
The name server found an internal inconsistency in its
database and could not return a valid answer.
The name server refused to service the request.
The name server found that the request packet was not in the
nslookup was developed by the University of California, Berkeley.
/etc/resolv.conf Initial domain name and name server
$HOME/.nslookuprc User's initial options
named(1M), resolver(3N), resolver(4), nsswitch.conf(4), hostname(5),
Hewlett-Packard Company - 8 - HP-UX Release 11i: November 2000