|

How To Use The Nslookup Command In Windows (2027)

Nslookup is the built-in Windows tool for asking a DNS server what IP address sits behind a name.

Open Command Prompt, type nslookup example.com and press Enter to get an answer in a second or two.

This guide covers the one-line lookups, the interactive mode and what each error message means, all taken from Microsoft’s own documentation.

Table of Contents

Nslookup quick answers

I want toType this
Look up the IP address of a namenslookup mydomain.com
Look up the name behind an IP addressnslookup 4.4.4.4
Ask a specific DNS servernslookup mydomain.com 1.1.1.1
Return only IPv6 (AAAA) recordsnslookup -type=AAAA mydomain.com
Start interactive modenslookup

What the nslookup command does

Microsoft describes nslookup as a tool that displays information you can use to diagnose Domain Name System (DNS) infrastructure.

It works on Windows 11 and Windows 10, plus the supported Windows Server releases.

Microsoft notes that the tool is available only if the TCP/IP protocol is installed, which is the case on a normal Windows PC.

Nothing needs to be downloaded, because the command ships with Windows.

How to open the command line

  1. Press the Windows key and type cmd.
  2. Select Command Prompt from the results.
  3. Type your nslookup command and press Enter.

The command also runs in PowerShell and in scripts, because noninteractive mode is built for single lookups in command lines.

You do not need administrator rights for a plain lookup.

To open the console with elevated rights anyway, follow our guide to opening Terminal as administrator in Windows 11.

Look up a name or IP address (noninteractive mode)

In noninteractive mode the first parameter is the name or IP address you want to look up.

The optional second parameter is the name or IP address of a DNS name server.

If you leave the second one out, nslookup uses your default DNS name server.

  1. Type nslookup mydomain.com to see the IP addresses for that name from your default server.
  2. Type nslookup 4.4.4.4 to see the domain name for an IP address.
  3. Type nslookup mydomain.com 1.1.1.1 to send the same question to the server at 1.1.1.1 instead.

Microsoft explains that when you look up an IP address and the query is for an A or PTR record type, the name of the computer is returned.

Ask a different DNS server

Naming a second server is the quickest way to tell whether your own DNS server is the problem.

If the default server fails but another server answers, the fault sits with the default server and not with the site.

To change which server Windows uses day to day, see how to change the DNS server in Windows 11.

Useful command-line options

OptionWhat it does
-debugTurns on debug output so you can see more about the packets sent.
-type=AAAAReturns only IPv6 (AAAA) records.
-type=A+AAAAReturns both IPv4 and IPv6 addresses, as in Microsoft’s combined example.
-nosearchSkips the DNS domain search list.
-recurseAsks the server to query other servers when it lacks the answer.

Microsoft’s page shows these combined in one line: nslookup -debug -type=A+AAAA -nosearch -recurse mydomain.com 1.1.1.1.

Use interactive mode for several lookups

Interactive mode suits you when you have several names to look up or several settings to change.

  1. Type nslookup on its own and press Enter, or type nslookup - 1.1.1.1 to start with a chosen default server.
  2. Wait for the prompt to change to >.
  3. Type a name or IP address on each line to look it up.
  4. Type exit to leave.

Press Ctrl+B at any time to interrupt an interactive command.

An unrecognized command is read as a computer name, so put a backslash before a built-in command word when you really mean a host with that name.

Interactive subcommands

SubcommandWhat it does
serverChanges the default server to the one you name.
set allPrints the current values of the configuration settings.
set type=HINFOChanges the resource record type for the query.
set debugTurns debugging mode on or off.
set timeoutChanges how many seconds nslookup waits for a reply.
set retrySets the number of retries.
helpShows a short summary of subcommands.

A typical session on Microsoft’s page runs set all, looks up a domain, then switches to server 4.4.4.4 and repeats the lookup.

Subcommands you rarely need

The ls subcommand lists information for a DNS domain, and view sorts and lists the output of the previous ls command.

The root subcommand changes the default server to the server for the root of the DNS domain name space.

The set port subcommand changes the default TCP/UDP DNS name server port to the value you give it.

Microsoft notes that a Connection refused message commonly shows up with ls and finger requests.

When the name you type has no trailing period, nslookup appends the default DNS domain name before it asks.

That behavior depends on the domain, srchlist, defname and search settings.

With search turned on, the DNS domain names in your search list are added to the request until an answer comes back, provided the name contains at least one period but does not end with one.

Add a trailing period to a name, as in mydomain.com., when you want to be sure only that exact name is queried.

What the nslookup error messages mean

MessageMeaning (per Microsoft)
timed outThe server did not respond after a certain time and number of retries. Adjust with set timeout and set retry.
No response from serverNo DNS name server is running on the server computer.
No recordsThe name is valid, but the server has no records of the current query type. Set the type with set querytype.
Nonexistent domainThe computer or DNS domain name does not exist.
Server failureThe server found an internal inconsistency in its database and could not return a valid answer.
RefusedThe DNS server refused to service the request.
Connection refused or Network is unreachableThe connection to the DNS server or finger server could not be made, which commonly happens with ls and finger requests.

What to do when lookups fail

  1. Run the lookup again against a different server, such as nslookup mydomain.com 1.1.1.1.
  2. If only your default server fails, change your DNS server in Windows.
  3. If every server times out, check the connection itself with Ping and Tracert.
  4. If a name returns No records, retry with another query type.

You can also review open connections with Netstat when a program seems to reach the wrong host.

Official sources

Everything above comes from Microsoft’s nslookup reference.

Microsoft also publishes a Command-Line Syntax Key that explains the brackets and braces in its syntax lines.

Leave a Reply

Your email address will not be published. Required fields are marked *