nslookup - Look Up DNS Records

Maintained on

The nslookup command queries a DNS server and shows how a domain name maps to an IP address (the result of name resolution).

When a website won’t load or email isn’t arriving, it is a good first step for finding out whether DNS is the cause.

Basic syntax of the nslookup command

nslookup [-<option>] [<name or IP address to look up>] [<DNS server to query>]

If you run it without arguments, it starts interactive mode, described below.

Look up an IP address from a domain name

Specify the domain name you want to look up.

nslookup example.com
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>nslookup example.com
Server: dns.google
Address: 8.8.8.8
Non-authoritative answer:
Name: example.com
Addresses: 2606:2800:21f:cb07:6820:80da:af6b:8b2c
93.184.216.34
C:\users\user>

The output has two parts.

  • The first two lines: the name and address of the DNS server that received the query (the one configured on your PC)
  • The rest: the domain name you looked up and its IP addresses
What "Non-authoritative answer" means

A “Non-authoritative answer” means the reply came from an intermediate DNS server that holds a cache, not from the DNS server that actually manages the domain. It appears often in normal queries and is not an error.

Your output will differ

The output above is only an example. The DNS server name and the number and order of IP addresses depend on your network and when you run the query.

Look up a domain name from an IP address (reverse lookup)

If you specify an IP address instead of a domain name, nslookup performs a reverse lookup to find the host name for that address.

nslookup 8.8.8.8
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>nslookup 8.8.8.8
Server: dns.google
Address: 8.8.8.8
Name: dns.google
Address: 8.8.8.8
C:\users\user>
おすすめ書籍※ 広告を含む場合があります
中小企業経営者のためのRPA入門 RPA導入を成功させる方法

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超入門

60分でわかる! AIエージェント 超入門

コマンドラインの黒い画面が怖いんです。

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

For an IP address that has no reverse record (PTR record), no name is found and an error may appear.

If the DNS server you are querying has no PTR record for its own address, the first line shows Server: UnKnown. This has nothing to do with your query result and is not an error.

Query a specific DNS server

If you specify a DNS server as the second argument, nslookup queries that server instead of the one configured on your PC.

nslookup example.com 1.1.1.1

If the result differs from your PC’s default DNS server, the settings or cache of the default server may be the problem.

This is also useful right after you change DNS records, to check whether the change has propagated to several servers.

Specify the record type

DNS stores many kinds of information (records) besides IP addresses. Use the -type= option to choose which kind to look up.

nslookup -type=<record type> <domain name>
Record typeDescription
AIPv4 address for the domain name
AAAAIPv6 address for the domain name
MXWhere mail is delivered (mail servers)
NSName servers that manage the domain
TXTText information (also used for email authentication like SPF)
CNAMEAlias (points to the canonical name)
SOAAdministrative information about the domain
PTRHost name for an IP address (used for reverse lookups)
ANYAll records (some servers do not respond to this)

Look up mail servers (MX records)

nslookup -type=MX example.com

When email isn’t arriving, you can check whether the destination mail servers are configured correctly.

Look up name servers (NS records)

nslookup -type=NS example.com

You can see which DNS servers are responsible for the domain. This is commonly used after a domain transfer or a change of DNS settings.

Look up TXT records

nslookup -type=TXT example.com

You can check strings used to verify domain ownership, as well as email authentication settings such as SPF.

Use interactive mode

If you run nslookup without arguments, a > prompt appears and you can enter queries repeatedly.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>nslookup
Default Server: dns.google
Address: 8.8.8.8
> set type=MX
> example.com
(the MX record results are displayed)
> exit
C:\users\user>

These are the commands you will use most often in interactive mode.

CommandDescription
set type=<type>Change the record type to look up
server <DNS server>Change the DNS server to query
<domain name>Query the name you typed
exitLeave interactive mode

Interactive mode is more efficient when you want to query the same domain repeatedly while changing the record type or DNS server.

How to read error messages

Non-existent domain

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>nslookup example.invalid
Server: dns.google
Address: 8.8.8.8
*** dns.google can’t find example.invalid: Non-existent domain
C:\users\user>

The domain name you queried does not exist in DNS. Possible causes are a typo in the domain name, or a domain that was never registered or has expired.

DNS request timed out

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>nslookup example.com 192.0.2.1
Server: UnKnown
Address: 192.0.2.1
DNS request timed out.
timeout was 2 seconds.
*** Request to UnKnown timed-out
C:\users\user>

The output varies by Windows version.

This means the DNS server did not reply in time. Possible causes are a wrong DNS server address, no network connection, or a firewall blocking DNS (port 53 over UDP/TCP).

Understand the difference from ping

ping resolves host names through your PC’s own name resolution mechanism (including the hosts file and the DNS cache), whereas nslookup queries the DNS server directly. So if nslookup succeeds but ping cannot resolve the name, the cause may be a PC-side setting such as the hosts file or the local cache. Conversely, if ping connects to a different address than nslookup shows, a hosts file entry may be responsible. You can view the DNS cache with ipconfig /displaydns and clear it with ipconfig /flushdns.

Using it in a batch file

You can filter the output of nslookup with the findstr command to pick out only the lines you need.

@echo off

nslookup -type=MX example.com | findstr /i /c:"mail exchanger"

The | (pipe) passes the output of nslookup to findstr. Because findstr treats a space in the search string as “or”, /c: is added so that the whole string mail exchanger is searched. As a result, only the MX record lines (MX preference = ..., mail exchanger = ...) are displayed.

The actual output depends on how the domain is configured.

Processing that depends on the output format is fragile

The format of the nslookup output can change with the Windows version, the display language, and the information returned. Processing that assumes a specific line or position in the output may stop working when the environment changes, so test it thoroughly.

Practice questions

Practice Problem

Which command looks up a domain’s mail servers (MX records)?

回答がサーバーに送信されることはありません
Practice Problem

Which description of nslookup example.com 1.1.1.1 is correct?

回答がサーバーに送信されることはありません
#Command Prompt #Batch Files #Command Line #Commands #Network #DNS