Chapters (20)

Checking DNS records with dig and nslookup

The short version

  • A lookup tool lets you ask DNS a question and see the raw answer.
  • The best-known tool is dig. Windows has nslookup and a PowerShell command instead.
  • You give it a name, and (if you want) a record type.
  • You can also pick which server to ask.

Why bother?

Earlier chapters showed you what each record does. Sooner or later you'll want to see one for real. Maybe you've just changed a record and want to know if it took.

Lookup tools let you do that. They ask a question and print the answer. Nothing more.

dig

dig is a flexible tool for interrogating DNS name servers.[1] That's the official description. In plain words: it asks a question and shows you the reply.

Windows doesn't include it, as the chapter on pointing a domain at a host notes.

A typical dig command looks like this:[1]

dig @server name type
The command dig @8.8.8.8 example.com MX with three arrows. The first points to who to ask, optional, a resolver. The second points to what to look up, the domain name. The third points to which record, optional, A if left out.
The three parts of a dig command.

Here's what each part means:

  • server is the name or IP address of the name server to query.[1] It's optional.
  • name is the domain you're looking up, like example.com.
  • type is the record type, like MX or TXT. Leave it out and dig looks up an A record.[1]

Try it on a documentation domain:

$ dig example.com MX

The answer prints the question, the records it found, and some extra detail about the reply. Each record line shows its name, its TTL, the record type and its value. You met that layout in the TTL chapter.

Cutting down the noise

The full output is long. Add +short and you get a terse answer instead.[1]

$ dig NS example.com +short

Short output is handy when you only want to compare values. The nameservers chapter uses it.

Asking a different server

Say you've just changed a record. Your own resolver might still hold an old copy. Ask a different server and compare:

$ dig @198.51.100.53 example.com A

The address 198.51.100.53 is made up. It comes from a range kept for examples. If the two answers differ, one resolver still has an old copy. The caching chapter explains why.

Following the trail with +trace

The +trace option traces the delegation path from the root name servers for the name you're looking up.[1]

Three boxes joined by arrows: root servers, then .com servers, then example.com servers. Text says dig +trace starts at the root and follows each handoff by itself.
dig +trace walks down from the root.

In other words, dig starts at the top and follows each hand-off for you. You see root, then the top-level domain, then your domain's own nameservers.

If a lookup fails, the header of the full output holds a code that says why. The error codes chapter explains each one.

Looking up a name from an address

You can go the other way too. The -x option sets up a reverse lookup, which maps an address to a name.[1] The reverse DNS chapter explains how that works.

$ dig -x 192.0.2.1

nslookup on Windows

Microsoft says nslookup displays information you can use to diagnose DNS.[2] It has two modes: interactive and noninteractive.[2]

For a one-off check, use the plain form. Pick a record type with the -type= option:[2]

> nslookup -type=MX example.com

Microsoft's own example asks for IPv6 addresses with nslookup -type=AAAA mydomain.com.[2]

PowerShell

PowerShell has Resolve-DnsName. It performs a DNS name query for the name you give it.[3] Add -Type to choose a record type. Add -Server to choose the servers to ask.[3]

> Resolve-DnsName example.com -Type MX -Server 198.51.100.53

Leave out -Server and it asks the interface DNS servers by default.[3]

The same question, three ways

A table of three tools. dig is not included in Windows: dig example.com MX. nslookup is a Windows command: nslookup -type=MX example.com. PowerShell has Resolve-DnsName: Resolve-DnsName example.com -Type MX.
The same MX question in three tools.

They all ask the same thing, so use whichever one your computer has.

No tool handy?

A web page can do the same job. Google's Admin Toolbox has a Dig page that needs no install.

Google Admin Toolbox Dig, with example.com entered and A selected. The results show two A records, each with a TTL of 5 minutes and an IPv4 address.
An A lookup for example.com returns two addresses. Screenshot: Google Admin Toolbox, captured 2026-10-18.

Next: pointing your domain

Now that you can check a record, you can use that skill on a real move. The last chapter walks through pointing a domain at a host.

Sources

  1. BIND 9 manual pages: dig, Internet Systems Consortium (BIND 9 documentation) (accessed 2026-10-31)
  2. nslookup, Microsoft Learn (accessed 2026-10-31)
  3. Resolve-DnsName, Microsoft Learn (accessed 2026-10-31)