nslookup commands cheat sheet

This cheat sheet brings together the commands of nslookup, the DNS testing tool available on every Windows computer and also on Linux and macOS: queries by record type, querying a specific DNS server, interactive mode, checking email records, and reading the output and error messages. You can search for a command, filter by topic, and copy it with one click.

Basic queries

  • nslookup example.com

    Shows the IP addresses of the name, using the DNS server set on the computer. The first lines show the name and address of the server that answered, followed by the answer.

    Example: Name: example.com Address: 192.0.2.10

  • nslookup example.com 192.0.2.53

    Sends the query to a specific DNS server instead of the one set on the computer. The second argument can be an IP address or a server name.

  • nslookup example.com 1.1.1.1

    Queries a well-known public DNS server. Comparing its answer with the local server's answer shows whether the problem is in your network's DNS server.

  • nslookup 192.0.2.10

    Reverse lookup: when the argument is an IP address, the tool returns the name (PTR record) set for the address.

    Example: 10.2.0.192.in-addr.arpa name = mail.example.com.

  • nslookup 2001:db8::10

    Reverse lookup for an IPv6 address, the same way as for an IPv4 address.

  • nslookup -debug example.com

    Shows full details of the query and the answer, including the TTL of each record. You can write any interactive mode setting this way on the command line, with a hyphen before it.

  • nslookup -timeout=10 -retry=3 example.com 192.0.2.53

    Extends the wait for an answer to 10 seconds and sets 3 retries, for a server that answers slowly. The options are written before the name.

  • nslookup -version

    On Linux: shows the nslookup version and exits. The option doesn't exist on Windows.

Queries by record type

  • nslookup -type=MX example.com

    Shows the domain's mail servers. The number (preference in the Windows output) is the priority: the lower the value, the higher the priority.

    Example: example.com MX preference = 10, mail exchanger = mail.example.com

  • nslookup -type=TXT example.com

    Shows the domain's TXT records, including the SPF record and ownership verification records.

  • nslookup -type=NS example.com

    Shows the nameservers that manage the domain.

    Example: example.com nameserver = ns1.example.com

  • nslookup -type=SOA example.com

    Shows the zone's SOA record: the primary nameserver, the administrator's email address, the serial number, and the refresh timers.

  • nslookup -type=AAAA example.com

    Shows only the domain's IPv6 addresses.

  • nslookup -type=CNAME www.example.com

    Checks whether the name is set as an alias (CNAME) of another name, and shows the target name.

    Example: www.example.com canonical name = example.com

  • nslookup -type=PTR 192.0.2.10

    Reverse lookup with an explicit record type. The result is the same as a lookup by IP address alone.

  • nslookup -type=SRV _imaps._tcp.example.com

    Shows an SRV record, whose name combines the service and the protocol, each prefixed with an underscore. The answer includes the priority, weight, port, and server name.

  • nslookup -type=CAA example.com

    Shows which certificate authorities are allowed to issue SSL certificates for the domain. The CAA type isn't listed among the record types in the Windows documentation, so it is best to run this check on Linux or macOS.

  • nslookup -type=ANY example.com

    Asks for all the records of the name. Many servers return only a partial answer to this query, so for a full check, query each record type separately.

  • nslookup -querytype=MX example.com

    The same as writing the type option. Both forms appear in the Windows and Linux documentation.

Interactive mode

  • nslookup

    Without arguments, the tool enters interactive mode and shows the > prompt. Type a name or an IP address on each line to get an answer, without typing the command again.

    Example: > example.com

  • nslookup - 192.0.2.53

    Enters interactive mode with a specific DNS server as the default server. The hyphen takes the place of the name to look up.

  • set type=MX

    Changes the record type for all the following queries, until the next change. The set querytype=MX command is the same. The default is addresses (A, and on Linux also AAAA).

  • server 192.0.2.53

    Changes the DNS server the following queries are sent to. When you write a server name instead of an address, the name is looked up through the current server.

  • lserver 192.0.2.53

    Like server, except that the new server's name is looked up through the original server the tool started with. Useful when the current server doesn't respond.

  • set all

    Shows the current settings and the default server.

  • set debug

    Shows all the details of the answer, including the TTL of each record. The set nodebug command turns off debug mode. The default is nodebug.

  • set d2

    Detailed debug mode: also shows the details of the query that was sent and all the fields of every packet. The set nod2 command turns it off.

  • set timeout=5

    Sets how many seconds to wait for an answer. On Windows, the default is 2 seconds.

  • set retry=3

    Sets how many times to send the query again when there is no answer. On Windows, the default is one retry.

  • set vc

    Sends the queries over TCP instead of UDP. Useful for checking that the DNS server also answers over TCP. The set novc command switches back to UDP, which is the default.

  • set norecurse

    Asks the server to answer only from what it already knows, without querying other servers. The set recurse command restores the default.

  • set port=5353

    Sends the queries to a port other than port 53, for example to a local DNS server used for testing.

  • exit

    Exits interactive mode. On Windows, you can stop a long query with Ctrl+B.

Authoritative server and propagation checks

  • nslookup example.com ns1.example.com

    Queries the domain's nameserver directly. When the server is authoritative for the domain, the Non-authoritative answer line doesn't appear, and the answer shows the value currently set in the zone.

  • nslookup -type=SOA example.com ns1.example.com

    Shows the zone's serial number on a specific nameserver. When the number is the same on all the domain's nameservers, the latest change has reached all of them.

  • nslookup -norecurse example.com 192.0.2.53

    Queries a DNS server without requesting recursion, so it answers only from what it already has stored or from the zones it manages.

  • nslookup example.com 8.8.8.8

    A query to another public server. When the servers return different answers, some of them still keep the previous value in their cache until its TTL expires.

  • nslookup -debug example.com 1.1.1.1

    Shows the TTL left for the record in the public server's cache, that is, the maximum number of seconds until the server checks it again.

Checking email records

  • nslookup -type=TXT example.com 8.8.8.8

    Shows the TXT records as a public DNS server sees them. The SPF record is the line that starts with v=spf1. A domain should have only one SPF record.

    Example: "v=spf1 mx ip4:192.0.2.25 -all"

  • nslookup -type=TXT _dmarc.example.com

    Shows the DMARC record, which is always published at the _dmarc name in front of the domain name.

    Example: "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com"

  • nslookup -type=TXT selector1._domainkey.example.com

    Shows the DKIM public key. Instead of selector1, write the selector name, which appears in the s= tag of the DKIM-Signature header of a message sent from the domain.

  • nslookup -type=MX example.com 1.1.1.1

    Shows the mail servers as a public DNS server sees them, that is, the way other mail servers around the world get them.

  • nslookup 192.0.2.25

    Shows the reverse name (PTR) of the mail server's address. Many mail servers check that the sending address has a reverse name, and that the name points back to the same address.

    Example: 25.2.0.192.in-addr.arpa name = mail.example.com.

Reading the output and error messages

  • Server: / Address:

    The first two lines of the output show the name of the DNS server that answered and its address. On Linux, the port also appears after the address, for example 192.0.2.53#53.

    Example: Server: UnKnown Address: 192.0.2.53

  • Server: UnKnown

    On Windows: this usually appears when the DNS server's address has no name in a reverse lookup (PTR), so the tool doesn't show its name. The message isn't an error, and the answer below it is valid.

  • Non-authoritative answer:

    The answer came from a DNS server that isn't authoritative for the domain, usually from its cache. This is normal when you query your internet provider's server or a public server, and it isn't a problem.

  • *** UnKnown can't find example.com: Non-existent domain

    On Windows: the name doesn't exist in DNS at all. Check the name for typos and make sure the record was added to the correct zone.

  • ** server can't find example.com: NXDOMAIN

    On Linux: the same answer in different wording. The name doesn't exist in DNS at all.

  • *** Can't find example.com: No answer

    On Linux: the name exists, but it has no records of the queried type. For example, an MX query for a name that has only an A record.

  • DNS request timed out.

    On Windows: the DNS server didn't answer within the set time, even after the retries. When the message keeps repeating, the server is unavailable or a firewall is blocking the connection to it.

    Example: timeout was 2 seconds.

  • SERVFAIL / Server failed

    The DNS server couldn't process the query. Common causes are authoritative nameservers that don't respond, or a DNSSEC validation failure for the domain.

  • REFUSED / Query refused

    The server refused to answer, for example a nameserver that doesn't manage the domain, or a DNS server that doesn't accept queries from external addresses.

The PowerShell alternative

  • Resolve-DnsName example.com -Type MX

    The PowerShell command for DNS queries on Windows. The output is returned as objects, so it is easy to filter and keep working with it in a script.

  • Resolve-DnsName example.com -Type TXT -Server 192.0.2.53

    A query to a specific DNS server, the equivalent of nslookup with a server as the second argument.

Names and addresses in the examples

The examples on this page use the example.com domain and IP addresses reserved for documentation, such as 192.0.2.10 and 2001:db8::10, so replace them with your own domain name and addresses. The addresses 1.1.1.1 and 8.8.8.8 are well-known public DNS servers, and they are a good way to check the answer the rest of the world gets.

Differences between Windows and Linux

On Windows, the tool is installed on every computer, and you run it from the Command Prompt or PowerShell. The tool is also available on macOS. On Linux, the version installed is the one that comes with the BIND DNS tools, in the same package as dig. The commands are mostly the same, but the output and error messages are worded differently, and this page notes where they differ. On Linux, without a specified record type, the tool shows both IPv4 and IPv6 addresses.

When the answer is correct but your computer still sees an old address

nslookup queries the DNS server directly, so it may show the new address while your browser and computer still use the previous address from the local cache. In this case, flushing the DNS cache on your computer and in your browser helps.

Did you know?

With our Cloudflare services, we connect your domain to Cloudflare and copy all your existing DNS records, including your email records. After the move, you can use the nslookup -type=NS example.com command to confirm that the new nameservers are already published.

Cloudflare services

nslookup commands FAQ

How do I check a domain's MX record on Windows?

Open the Command Prompt or PowerShell and run nslookup -type=MX example.com, replacing example.com with your domain. The answer lists each mail server with its priority (preference), and the lower the value, the higher the priority. To see what other mail servers around the world see, add a public DNS server at the end, for example nslookup -type=MX example.com 1.1.1.1.

What does Non-authoritative answer mean?

The message means the answer came from a DNS server that doesn't manage the domain, usually from the cache of your network's or internet provider's DNS server. This is normal, and the answer is valid. To get an authoritative answer, query the domain's nameserver directly, for example nslookup example.com ns1.example.com.

Why does nslookup show Server: UnKnown?

On Windows, nslookup tries to show the name of the DNS server that answers the queries. UnKnown usually appears instead of the name when the server's address has no name in a reverse lookup (PTR record). The message doesn't indicate a problem, and the answer below it is valid.

How do I check with nslookup whether a DNS change has propagated?

First, query the domain's nameserver, for example nslookup example.com ns1.example.com. When it returns the new value, the change is saved in the zone. Then query public DNS servers, such as nslookup example.com 1.1.1.1 and nslookup example.com 8.8.8.8. A server that still returns the previous value is keeping it in its cache, and it will pick up the new value once the record's TTL expires, at the latest.

When should I use nslookup and when should I use dig?

nslookup is available on every Windows computer and shows a short, clear answer, so it is handy for a quick check of an address, an MX record, or a TXT record. dig shows the server's full answer, including the flags and the TTL, and it suits in-depth diagnosis of DNS problems on Linux servers. The dig commands page brings together the dig commands.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement