nslookup Command

Purpose

Queries the internet Domain Name System (DNS) interactively.

Syntax

nslookup [ - option ] [ name | - ] [ server ]

Description

The nslookup command queries internet domain name servers in the following two modes:
Interactive mode
Allows you to query the name servers for information about various hosts and domains, or to print a list of the hosts in a domain.
Noninteractive mode
Prints the names and requested information for a specified host or a domain
The nslookup command enters interactive mode when no arguments are given, or when the first argument is a - (hyphen) and the second argument is the hostname or IP address of a name server. When no arguments are given, the command queries the default name server. The nslookup command enters noninteractive mode when the name or IP address of the host to be looked up is specified as the first argument. The optional second argument specifies the hostname or address of a name server. You can specify options 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, enter the following command:
nslookup -query=hinfo  -timeout=10
The -version option causes the nslookup command to print the version number and exit.

Interactive commands

Item Description
host [server] Looks up information for host by using the current default server or by using the specified server. If the host is an IP address and the query type is A or PTR, the nslookup command returns the name of the host. If the host is a name and does not have a trailing period, the search list is used to qualify the name. To look up a host that is not in the current domain, append a period to the name.
server Domain | lserver Domain Changes the default server to the value specified by the Domain parameter. The lserver subcommand uses the initial server to look up information about the domain. The server subcommand uses the current default server. If an authoritative answer cannot be found, the names of any additional servers that might have the answer are returned.
exit Exits the program.
set Keyword [= Value] Changes state information that affects lookups. You can specify the following keywords:
all
Prints the current values of the frequently used options to set command. Information about the current default server and host is also printed.
class= value
Changes the query class to one of the following value. The class specifies the protocol group of the information. The default value is IN.
IN
The Internet class.
CH
The Chaos class.
HESIOD
The Hesiod class.
ANY
Wildcard (any of the options).
[no]debug
Turns on debugging mode. The default value is nodebug.
[no]d2
Turns on comprehensive debugging. The default value is nod2.
domain=name
Changes the default domain name to the name specified by the name parameter.
[no]search
Appends the domain names in the domain search list to the request until an answer is received, if the lookup request contains a period other than a trailing period. The default value is search.
port=value
Changes the default transmission control protocol TCP/UDP name server port to the number specified by the value parameter. The default value is 53.
querytype=value type=value
Changes the type of the information query to the type specified by the value parameter. The default value is A.
Note: You can specify only one query type. Only the default behavior looks up both when an alternative is not specified.
[no]recurse
Tells the name server to query other servers if it does not have the information. The default value is recurse.
ndots=number
Sets the number of dots (label separators) in a domain that disables the search function. Absolute names always stop the search function.
retry=number
Sets the number of retries to the number specified by the number parameter.
timeout=number
Changes the initial timeout interval for waiting for a reply to the seconds specified by the number parameter.
[no]vc
Always uses a virtual circuit to send requests to the server. The default value is novc.
[no]fail
Tries the next name server if a name server responds with SERVFAIL or a referral (nofail) or stop query (fail) on such a response. The default value is nofail.

Return values

The nslookup command returns with an exit status of 1 if a query fails and returns 0 otherwise.

IDN support

If the nslookup command is built with internationalized domain name (IDN) support, it can accept and display non-ASCII domain names. The nslookup command converts character encoding of a domain name when it sends a request to a DNS server or displays a reply from the server. To turn off IDN support, define the IDN_DISABLE environment variable. IDN support is disabled if the IDN_DISABLE environment variable is set when the nslookup command runs, or when the standard output is not a tty.

Files

Item Description
/etc/resolv.conf Contains the initial domain name and name server addresses.