Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > N


BIND 9.3
HP-UX 11i Version 3: February 2007

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index


nslookup — query name servers interactively


Single Host Mode

nslookup [-swdebug] [-setoption]... host [server]

Interactive Mode

nslookup [-swdebug] [-setoption]... [- [server]]


The nslookup program queries Internet domain name servers. It follows the configured name resolution algorithm of the host and queries NIS, DNS, and host tables.

In Single Host Mode (noninteractive), nslookup queries a name server for information about one host or domain. This mode occurs when you specify a host in the command.

In Interactive Mode, nslookup lets you make several requests in the same session. For example, you can query a name server for information about various hosts and domains or print a list of hosts in the domain. This mode occurs when you omit the host (and server) in the command or when you use the special - placeholder.



Set the setoption, as defined for the set command. See The set Command subsection in the INTERACTIVE COMMANDS section.


Turn on tracing during command initialization, causing the switch module to print out a trace of the scan and parse actions on the hosts database entry in the /etc/nsswitch.conf file (see nsswitch.conf(4)). It may be used to debug syntactic errors in the switch configuration file. See also the set option [no]trace.

Note: swdebug is not a set command option, so you cannot turn it off in interactive mode.



The host name or IP address of a host system. If host is present, the command is executed immediately (noninteractively). If it is omitted, nslookup enters interactive mode.


Set interactive mode. This placeholder is needed if you specify server for interactive mode.


The host name or IP address of a domain name server. If omitted, nslookup uses the policy described in the Default Lookup Policy subsection.

Initialization File

The setoptions and swdebug (see the Options subsection) can be specified in a .nslookuprc startup file in the user's home directory. Enter them one per line without the leading hyphen (-).

Default Lookup Policy

If a server has not been specified explicitly to override the switch policy, nslookup initializes each of the name services in the hosts database in the switch configuration file /etc/nsswitch.conf (see nsswitch.conf(4)), but uses the first name service for lookup. The initialization of the name services may cause a delay in obtaining the response if any of the name services is not responding. For example, consider when the hosts database is defined with the following name services:

hosts : files dns nis

If the name servers mentioned in /etc/resolv.conf (see resolver(4)) are unavailable, there will be a delay in trying to initialize the name servers. The handling of the query thereafter follows the switch policy, as would be expected.

nslookup contacts the name servers mentioned in /etc/resolv.conf sequentially but does not cycle through them like the resolver routines do (see resolver(3N)).

Note: nslookup should not be used as a command-line substitute for the resolver routines unless the differences in resolution behavior between nslookup and the resolver routines are understood and are acceptable for the scripting environment where nslookup will be employed.

The following hosts name services are recognized:


Use the servers defined in the /etc/resolv.conf file.


Use the entries in the /etc/hosts file.


Use the maps at the NIS server.

Note: NIS+ is not supported by nslookup. If the nisplus name service is included in the hosts database, it is ignored.

If there is no hosts database in the /etc/nsswitch.conf file or there is no /etc/nsswitch.conf file, nslookup uses this name service sequence: dns nis files.

To override the switch policy and query DNS servers directly, you can specify a name server by entering the server operand on the command line or by using the server or lserver command in interactive mode. Whenever an action is taken that causes the switch policy to be overridden, a warning message is displayed.

If the first successful hosts name service is nis or files, nslookup has a reduced interactive command set; the help command shows which commands are currently valid.

Use the reset command in interactive mode to restore the default policy.


Commands can be interrupted at any time with the intr character, commonly Ctrl-C. To exit, type the eof character, commonly Ctrl-D, or use the exit command. (See stty(1).) 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.

General Commands

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; see The set Command. Answers from a name server's cache are labeled non-authoritative.


See the help command.


Exit the program.

finger [name] [> filename]

finger [name] [>> filename]

Connects with the finger server on the current host. name is a user name or user ID on the host; it is optional. The current host is defined when a previous lookup for a host was successful and returned address information. The output can create/overwrite (>) or append to (>>) filename.



Print a brief summary of commands that are valid in the current context.

ls [option] domain [> filename]

ls [option] domain [>> filename]

List information available for domain. The default output contains host names and their Internet addresses. option can be one of the following:


List aliases of hosts in the domain (synonym for -t CNAME).


List all records for the domain (synonym for -t ANY).


List CPU and operating system information for the domain (synonym for -t HINFO).


List well-known services of hosts in the domain (synonym for -t WKS).

-t querytype

List all records of the specified type. See querytype in The set Command.

The output can create/overwrite (>) or append to (>>) filename. When output is directed to a file, a # character is printed to standard output for every 50 records received from the server.

lserver domain

See the server command.


Print out the policy read from the hosts database in the switch configuration file (see nsswitch.conf(4)). 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. The four statuses of the criteria are represented by four characters in square brackets. The order of the status characters is:


The letters used in the four status positions are:

R Return. C Continue; try next name service, if any.

If no criteria are specified between two sources, then the default actions assigned to the statuses are [RCCC].


Return to using the configured name service switch policy and reset to the original name servers.


Change the default server to the server for the root of the domain name space. The root command is a synonym for lserver root-host, where root-host is the root server specified with the set root command. The default root server is ns.nic.ddn.mil.

server domain

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.

set [no]keyword[=value]

Change state information that affects lookups. See The set Command.

view filename

Sort and list the contents of filename, using more (see more(1)). This is useful for viewing files written by the finger and ls commands.

The set Command

The set command changes state information that affects the lookups. The options can also be entered as setoption values on the command line. For example, -all.


set [no]keyword

The prefix no negates the request. The no action is described in brackets ([...]).

set keyword[=value]

The keyword option is set to value.

Other characters in brackets ([...]) are optional, allowing for keyword abbreviations. Spaces are not permitted.



Print the current values of the various set options, along with information about the current default server and host.


Change the query class to one of:


The Internet class.


The Chaosnet class.


The MIT Athena Hesiod class.


Wildcard (any of the above).

The class specifies the protocol group of the information. The default is class=IN.


Turn on [turn off] exhaustive debugging mode. Essentially all fields of every packet are printed. The default is nod2.


Turn on [turn off] debugging mode. More information is printed about the packet sent to the server and the resulting answer. The default is nodebug.


Append [do not append] the default domain name to a single-component lookup request (that is, one that does not contain a period character). The default is defname.


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. The default is the value from host name, /etc/resolv.conf, or the LOCALDOMAIN environment variable.


Ignore [do not ignore] truncation errors. The default is noignore.


Change the default TCP/UDP name server port to value. The default is port=53.



Change the type of information returned from a query to one of:


Host's IPv4 address


Host's IPv6 address


All types of data


Canonical name for an alias


Group ID


Host CPU and operating system type


Mailbox domain name


Mail group member


Mailbox or mail list information


Mail rename domain name


Mail exchanger


Name server for the named zone


Host name if the query is an Internet address, otherwise the pointer to other information.


Start of authority record


Text information


User ID


User information


Well-known service description


Tell the name server to query [not to query] other servers if it does not have the information. The default is recurse.


Set the number of retries to number. When a reply to a request is not received within a certain amount of time (changed with the set timeout command ), the timeout period is doubled and the request is resent. The retry value controls how many times a request is resent before giving up. The default is retry=4.


Change the name of the root server to host. This affects the root command. The default is root=ns.nic.ddn.mil.


If the lookup request contains at least one period but doesn't end with a trailing period, append [do not append] the domain names in the domain search list to the request until an answer is received. See hostname(5). The default is search.


Change the default domain name to name1 and the domain search list to name1, name2, and so on. A maximum of 6 names separated by slashes (/) can be specified. For example,

set srchlist=lcs.MIT.EDU/ai.MIT.EDU/MIT.EDU

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. The default is a value based on the host name, /etc/resolv.conf, or the LOCALDOMAIN environment variable.


Display [do not display] information about the sources used for resolving a name or an address lookup. This flag traces the behavior generated by the switch policy. The default is noswtrace.


Change the initial timeout interval for waiting for a reply to number seconds. Each retry doubles the timeout period. The default is timeout=5.


See the querytype option.


Always use [do not use] a virtual circuit when sending requests to the server. The default is novc.


If the lookup request was not successful, an error message is printed. Possible error messages are:

Connection refused

The connection to the name server could not be made at the present time.

Format error

The name server found that the request packet was not in the proper format.

Network is unreachable

The connection to the name server could not be made at the present time.

No records

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.

No response from server

No name server is running on the server machine.

Non-existent domain

The host or domain name does not exist.


The name server refused to service the request.

Server failure

The name server found an internal inconsistency in its database and could not return a valid answer.


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).


To change the default query type to host information and the initial timeout to 10 seconds, and enter interactive mode:

nslookup -query=hinfo -timeout=10


nslookup was developed by the Internet Systems Consortium (ISC).



User's initial options.


Host name data base.


Configuration file for the name-service switch.


Initial domain name and name server addresses.


more(1), stty(1), named(1M), resolver(3N), hosts(4), nsswitch.conf(4), resolver(4), hostname(5).

Requests for Comments (RFC): 1034, 1035, available online at http://www.rfc-editor.org/.

HP-UX IP Address and Client Management Administrator's Guide, available online at http://docs.hp.com.

BIND 9 Administrator Reference Manual, available from the Internet Systems Consortium at http://www.isc.org/sw/bind/arm93.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.