This diagnostic tool displays information from Domain Name System (DNS) name servers. Before using this tool, you should be familiar with how DNS works. Nslookup is available only if the TCP/IP protocol has been installed.
Syntax
nslookup [-option …] [hostname | - [server]]
Modes
Nslookup has two modes: interactive and non-interactive.
If you only need to look up a single piece of data, use non-interactive mode. For the first argument, type the name or IP address of the host to be looked up. For the second argument, type the name or IP address of a DNS name server. If you omit the second argument, the default DNS name server will be used.
If you need to look up more than one piece of data, you can use interactive mode. Type a hyphen (-) for the first argument and the name or IP address of a DNS name server for the second argument. Or, omit both arguments (the default DNS name server will be used).
Parameters
-option …
Specifies one or more nslookup commands as a command-line option. For a list of these optional commands, see the following Table A.2, Nslookup Commands in Windows NT. Each option consists of a hyphen (-) followed immediately by the command name and, in some cases, an equal sign (=) and then a value. For example, to change the default query type to host information and the initial timeout to 10 seconds, you would type:
nslookup -querytype=hinfo -timeout=10
The command line length must be less than 256 characters.
hostname
Look up information for hostname using the current default server or using server if specified. If computer-to-find is an IP address and the query type is A or PTR, the name of the computer is returned. If hostname is a name and does not have a trailing period, the default DNS domain name is appended to the name. (You can change this behavior by using the nslookup set command. Refer to the following Table A.2, Nslookup Commands in Windows NT. To look up a computer not in the current DNS domain, append a period to the name.
If you type a hyphen (-) instead of hostname, the command prompt changes to nslookup interactive mode.
server
Host name of the DNS server to use. If you omit server, the default DNS name server is used.
Notes
Interactive Commands
Diagnostics
If the nslookup command fails, an error message prints. 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).
No DNS name server is running on the server.
The DNS name 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 name or DNS domain name does not exist.
– Or –
The connection to the DNS name server or Finger server could not be made. This error commonly occurs with ls and finger requests.
The DNS name server found an internal inconsistency in its database and could not return a valid answer.
The DNS name server refused to service the request.
The DNS name server found that the request packet was not in the proper format. It may indicate an error in nslookup.
The following table shows the nslookup commands. For details about syntax for individual nslookup commands, choose the nslookup commands topic in the TCP/IP Procedure Help.
Table A.2 Nslookup Commands in Windows NT
Command | Purpose |
exit | Exits interactive nslookup. |
finger | 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 the address information. |
help | Displays a brief summary of nslookup commands. |
ls | Lists information for a DNS domain. The default output contains host names and their IP addresses. (When output is directed to a file, hash marks (###) are printed for every 50 records received from the server.) |
lserver | Changes the default server to the specified DNS domain. Lserver uses the initial server to look up the information about the specified DNS domain. (This is in contrast to the server command, which uses the current default server.) |
root | Changes the default server to the server for the root of the DNS domain name space. Currently, the host G.ROOT-SERVERS.NET. is used. (This command is a synonym for lserver g.root-server.net.) The name of the root server can be changed with the set root command. |
server | Changes the default server to the specified DNS domain. Server uses the current default server to look up the information about the specified DNS domain. (This is in contrast to the lserver command, which uses the initial server.) |
set | Changes configuration settings that affect the behavior of the nslookup commands. |
set all | Prints the current values of the configuration settings. Also prints information about the default server and host.. |
set cl[ass] | Changes the query class. (The class specifies the protocol group of the information.) |
set [no]d2 | Turns exhaustive debugging mode on or off. Essentially all fields of every packet are printed. |
set [no] deb[ug] | Turns debugging mode on or off. With debugging on, more information is printed about the packet sent to the server and the resulting answer. |
set [no] def[name] | If set, appends the default DNS domain name to a single-component lookup request. (A single component is a component that contains no periods.) |
set do[main] | Changes the default DNS domain to the name specified. The default DNS domain name is appended to a lookup request depending on the state of the defname and search options. The DNS domain search list contains the parents of the default DNS domain if it has at least two components in its name. For example, if the default DNS domain is mydomain.mycompany.com, the search list is mydomain.mycompany.com and mycompany.com. Use the set srchlist command to specify a different list. Use the set all command to display the list. |
Set [no] ig[nore] | If set, ignores packet truncation errors. |
Set po[rt] | Changes the default TCP/UDP DNS name server port to the value specified. |
Set q[uerytype] | Changes the type of information query. More information about types can be found in RFC 1035. (The set type command is a synonym for set querytype.) |
set [no] rec[urse] | If set, tells the DNS name server to query other servers if it does not have the information. |
Set ret[ry] | Sets the number of retries. 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 re-sent before giving up. |
Set ro[ot] | Changes the name of the root server. This affects the root command. |
Set [no] sea[rch] | If set and the lookup request contains at least one period but does not end with a trailing period, appends the DNS domain names in the DNS domain search list to the request until an answer is received. |
Set srchl[ist] | Changes the default DNS domain name and search list. A maximum of six names separated by slashes (/) can be specified. This command overrides the default DNS domain name and search list of the set domain command. Use the set all command to display the list. |
Set ti[meout] | Changes the initial number of seconds to wait for a reply to a request. When a reply to a request is not received within this time period, the timeout is doubled and the request is re-sent. (The number of retries is controlled with the set retry option.) |
set ty[pe] | Changes the type of information query. More information about types can be found in RFC 1035. (The set type command is a synonym for set querytype.) |
set [no] v[c] | If set, always uses a virtual circuit when sending requests to the server. |
view | Sorts and lists the output of previous ls command(s). |
References
For in-depth coverage of nslookup, see DNS and BIND by Paul Albitz and Cricket Liu, published by O'Reilly and Associates.