nslookup

query Internet name servers interactively

Syntax:

nslookup [options...] [host | [-server]]

Options:

options
Any of the options listed in the ``set command keywords'' section below may be specified on the command line if they precede the arguments and are prefixed with a hyphen. For example, to change the default query type to host information and the initial timeout to 10 seconds, you would enter:

nslookup -query=hinfo -timeout=10

host
Look up information for host using the current default server.
server
Look up information using this server.

Description:

The nslookup utility lets you query Internet domain name servers. The utility has two modes: interactive and non-interactive. In interactive mode, you can query name servers for information about various hosts and domains or print a list of hosts in a domain. In non-interactive mode, nslookup just prints the name and requested information for a host or domain.


Note: The nslookup utility won't look at /etc/hosts even if the lookup keyword is used in /etc/resolv.conf.

The utility enters interactive mode when:

The utility enters non-interactive mode when the first argument is the name or Internet address of the host to be looked up. The optional second argument specifies the host name or address of a name server.

The options listed under the ``set command keywords'' section may be specified in the .nslookuprc file in your home directory, where they should be listed one per line.

Interactive commands

To interrupt a command at any time, press Ctrl -C . To exit, press Ctrl -D (EOF) or type exit. To treat a builtin command as a host name, place an escape character (\) before the command.

Note that the length of the command line must be less than 256 characters.


Note: Any unrecognized command will be interpreted as a hostname.

exit
Exit the utility.
finger [name] [> filename]
finger [name] [>> filename]
Connect with the finger server on the current host. The current host is defined when a previous lookup for a host completed successfully and returned address information (see the set querytype=A command). The name argument is optional. Note that you can use > and >> in the usual manner.
help
?
Print a brief summary of commands.
ls [option] domain [> filename]
ls [option] domain [>> filename]
List the information available for domain, optionally creating or appending to filename. If no option is given, the output contains hostnames and their Internet addresses. The option argument can be one of the following:
-a
List aliases of hosts in the domain. Synonym for -t CNAME.
-d
List all records for the domain. Synonym for -t ANY.
-h
List CPU and OS information for the domain. Synonym for -t HINFO.
-s
List well-known services of hosts in the domain. Synonym for -t WKS. When output is directed to a file, hash marks are printed for every 50 records received from the server.
-t querytype
List all records of the specified type (see querytype below).
root
Change the default server to the server for the root of the domain namespace. Because the host ns.nic.ddn.mil is currently used, this command is a synonym for lserver ns.nic.ddn.mil. You can change the name of the root server with the set root command.
set keyword[=value]
Change state information that affects the lookups. See the set command keywords section for details on the set command.
server domain
lserver domain
Change the default server to domain. The lserver form uses the initial server to look up information about domain while server uses the current default server. If an authoritative answer can't be found, the names of servers that might have the answer are returned.
view filename
Sort and list the output of previous ls commands with more.

set command keywords

all
Print the current values of set's most frequently used options as well as information about the current default server and host.
class=value
The class specifies the protocol group of the information (default is IN, abbreviation is cl). Change the query class to one of:
ANY
Query for any of the following.
CHAOS
Chaos class.
HESIOD
MIT Athena Hesiod class.
IN
Internet class.
[no]d2
Turn exhaustive debugging mode on. All fields of every packet are printed (default is nod2).
[no]debug
Turn debugging mode on. A lot more information is printed about the packet sent to the server and the resulting answer (default is nodebug, abbreviation is [no]deb).
[no]defname
Append the default domain name to a single-component lookup request; i.e. one that doesn't contain a period (default is defname, abbreviation is [no]def).
domain=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 (see below).

The domain search list contains the parents of the default domain if the domain 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 (default is the value from hostname, /etc/resolv.conf.<nid> /etc/resolv.conf file, or LOCALDOMAIN environment variable; abbreviation is do).

To specify a different list, use set srchlist (see below); to display the list, use set all.

[no]ignoretc
Ignore packet truncation errors (default is noignoretc, abbreviation is [no]ig)
port=value
Change the default TCP/UDP name server port to value (default is 53, abbreviation is po).
querytype=value
type=value
Change the type of information query to one of:
A
The host's Internet address.
CNAME
The canonical name for an alias.
HINFO
The host CPU and OS type.
MINFO
The mailbox, or mail-list information.
MX
The mail exchanger.
NS
The name server for the named zone.
PTR
The hostname if the query is an Internet address; otherwise the pointer to other information.
SOA
The domain's ``start-of-authority'' information.
TXT
The text information.
UINFO
The user information.
WKS
The supported well-known services.

The types (ANY, AXFR, MB, MD, MF, NULL) are described in the RFC 1035 document.

Default is A; abbreviations are q, ty.

[no]recurse
Tell the name server to query other servers if it doesn't have the information (default is recurse, abbreviation is [no]rec).
retry=number
Set the number of retries to number. When a reply to a request isn't received within a certain amount of time (changed with set timeout), the timeout period is doubled and the request is sent again. The number argument controls how many times a request is resent before nslookup gives up (default is 4, abbreviation is ret).
root=host
Change the name of the root server to host. This affects the root command (default is ns.nic.ddn.mil., abbreviation is ro).
[no]search
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 list to the request until an answer is received (default is search, abbreviation is [no]sea).
srchlist=name1/name2/...
Change the default domain name to name1 and the domain search list to name1, name2, etc. (default is the value based on hostname, /etc/resolv.conf.<nid> /etc/resolv.conf file, or LOCALDOMAIN environment variable; abbreviation is srchl).

You can specify a maximum of six names separated by slashes (/). For example, this command:

	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.

timeout=number
Change the initial timeout interval for waiting for a reply to the specified number of seconds. Each retry doubles the timeout period (default is 5, abbreviation is ti)
[no]vc
Always use a virtual circuit when sending requests to the server (default is novc, abbreviation is [no]v)

Diagnostics

If the lookup request wasn't successful, one of the following error messages may be printed:

Connection refused - Network is unreachable
The connection to the name or finger server couldn't be made at the current time. This error commonly occurs with ls and finger requests.
Format error
The name server found that the request packet wasn't in the proper format. This may indicate an error in nslookup.
No records
The server doesn't have resource records of the current query type for the host, although the hostname 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 hostname or domain name doesn't exist.
Refused
The name server refused to service the request.
Server failure
The name server found an internal inconsistency in its database and couldn't return a valid answer.
Timed out
The server didn't 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).

Files:

/etc/resolv.conf.<nid>
Initial domain name and name server addresses. If /etc/resolv.conf.<nid> exists then /etc/resolv.conf will be ignored.
$HOME/.nslookuprc
User's initial options.
/etc/nslookup.help
Summary of commands.

Environment variables:

HOSTALIASES
Contains host aliases.
LOCALDOMAIN
Overrides default domain.

See also:

named

RFC 1034, RFC 1035