Skip to content

How to Check DNS with dig: A Beginner's Guide

dig shows exactly what DNS returns, including status codes, flags and TTLs. This beginner guide covers the commands you need and how to read every part of the output.

10 min readUpdated Nov 19, 2026By XPASS Editorial Team

How to Check DNS with dig: A Beginner's Guide

When something is wrong with a website or email, you often need more than a simple "yes, the name resolves." You want to know which server answered, whether that answer was a cached copy, how long it will stay valid and whether the name servers themselves are set up correctly. A command-line tool called dig is built for exactly that. It prints the full DNS response in a structured way, and once you can read it, you can answer most basic DNS questions in under a minute.

This guide is written for beginners. It shows how to install dig if you do not have it, how to run your first query, how to read each part of the output, and how to ask for specific record types and specific servers. It finishes with a worked example, limits and a troubleshooting table. If you would rather start with a simpler tool, the article on checking DNS records with nslookup covers the basics with fewer details. You can use both tools; they ask the same kind of question.

What dig is and why people use it

DNS is the naming system defined in RFC 1034 and RFC 1035. Computers use it to turn names into answers: IP addresses for websites, mail server names for email and text strings for verification. A DNS query asks a question, and the response carries the answer plus extra information about who answered and how.

dig stands for "domain information groper," a name that tells you something about its personality. It does not hide anything. Compared with simpler tools, it shows:

  • The status of the query, such as success or failure of the name.
  • Flags that tell you whether the answer is authoritative or came from a cache.
  • The TTL, the number of seconds for which each record may be kept.
  • Which server answered and how long it took.
  • Extra sections that reveal the name servers responsible for the zone.

That extra detail is why dig is a favourite of people who manage domains. You can see in one screen whether a problem is a missing record, a cache that has not expired or a broken delegation.

Getting dig

dig is already available on macOS. On many Linux distributions it is part of a package with a name such as dnsutils or bind-utils, so if the command is not found, install that package with your system's package manager. On Windows, dig is not included by default; people typically use it through the Windows Subsystem for Linux, or install the BIND tools, or use nslookup instead. Check that it works by typing:

dig -v

It prints the version. If you see that, you are ready.

Your first query

The basic form is dig followed by a name:

dig example.com

By default dig asks for the A record, the IPv4 address. You will get a block of output with several parts. Here is a shortened version, with comments added:

; <<>> DiG 9.x <<>> example.com
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12345
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;example.com.            IN  A

;; ANSWER SECTION:
example.com.     300     IN  A   203.0.113.25

;; Query time: 24 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)

The exact version number and details will differ on your computer. The next section explains each part.

Reading the output

The header line. status: NOERROR means the query was handled normally. Other values you will meet are NXDOMAIN (the name does not exist), SERVFAIL (the server could not produce a valid answer) and REFUSED (the server declined to answer you).

The flags. Each flag is a short code. The ones beginners need:

Flag Meaning
qr This message is a response, not a query
rd Recursion desired: you asked the server to look things up for you
ra Recursion available: the server is willing to do so
aa Authoritative answer: the server holds the zone itself and is not repeating a cache

If aa is present, the answer came straight from the name server that owns the zone. If it is absent, you are looking at an answer passed along by a resolver, which may come from its cache.

The counts. ANSWER: 1 tells you the number of records in the answer section. A response with status NOERROR and ANSWER: 0 means the name exists, but there is no record of the type you asked for. That is different from NXDOMAIN, and mixing them up is a common mistake.

The question section. This repeats what you asked: the name, the class (IN means Internet) and the type. Check it. If you typed the wrong name or type, the question section shows it.

The answer section. Each line has the name, the TTL in seconds, the class, the type and the data. The TTL is how long the resolver that answered may keep this record. When you query a resolver repeatedly, you often see the TTL count down toward zero and then jump back up. That countdown is a sign that you are seeing a cached answer.

The footer. Query time is how long the answer took. SERVER shows which server you actually asked, which is worth reading every time: if you thought you were asking one server and the line shows another, your conclusion will be wrong.

Common record types and useful options

Add the record type after the name:

dig example.com AAAA
dig example.com MX
dig example.com TXT
dig example.com NS
dig www.example.com CNAME
dig example.com SOA

Handy options go before or after the name, starting with a plus sign:

Option What it does
+short Prints only the answer data, one line per record
+noall +answer Prints only the answer section, with names and TTLs
+nocmd Removes the first comment line
+trace Follows the lookup from the root servers down
+tcp Sends the query over TCP instead of UDP
-x Reverse lookup: dig -x 192.0.2.10 finds the name for an IP address

For example, dig +short example.com MX prints just the mail servers with their preference numbers. The lower the number, the higher the priority. dig +noall +answer example.com TXT prints the TXT records with their TTLs and nothing else, which is tidy enough to paste into a ticket.

Asking a specific server

By default dig asks the resolver configured on your computer. To ask another server, use an at sign:

dig @ns1.example.net example.com A

This is the single most useful habit in DNS troubleshooting, because it separates what is published from what is cached. First, find the zone's name servers with dig +short example.com NS. Then ask one of them directly. If the response has the aa flag and shows your new record, the record is published correctly. Then ask your normal resolver. If it shows an older record, you are waiting for the TTL on that older answer to run out. The article on how long DNS propagation takes explains why that waiting happens and how to shorten it.

Following a lookup with +trace

dig +trace example.com ignores your resolver's cache and walks the path itself. It starts with the root servers, then asks the servers for the top-level domain, then the domain's own name servers, printing each step. The root and top-level levels are part of the system overseen through IANA, which publishes the list of top-level domains in its Root Zone Database.

Use +trace when you suspect a delegation problem. For example, you changed name servers at your registrar but the old ones still seem to be in use. The trace shows which name servers the top-level domain hands out. If those are not the ones you set, the change has not reached the registry yet, or has not been saved at the registrar. A trace also helps when a lookup times out, because you can see at which step the chain stops answering.

Remember that +trace shows the path from where you are, using what each server says right now. It is a diagnostic aid, not a permanent record.

A worked example

Suppose you manage mybrand.example and have just created the www name. Visitors report an error on www.mybrand.example, while mybrand.example works.

  1. Run dig www.mybrand.example. The header says status: NXDOMAIN, and the authority section shows an SOA record with a TTL that counts down each time you repeat the query. The resolver says the name does not exist.
  2. Ask the domain's own name server: dig @ns1.dnshost.example www.mybrand.example. This time the status is NOERROR, the aa flag is present, and the answer section shows a CNAME pointing to mybrand.example. followed by its address. The record exists and is published correctly.
  3. Run dig www.mybrand.example against your default resolver again. It still says NXDOMAIN, and the SOA TTL in the authority section is lower than before.
  4. Conclusion: the record is fine. Someone looked up www before it was created, and the resolver is holding a cached "no such name" answer. That is called a negative answer, and its lifetime comes from the zone's SOA settings. Once the countdown reaches zero, the resolver will ask again and receive the real record.

This kind of cached negative answer is a surprise to many beginners. If you query a name before creating the record, resolvers may remember that nothing existed. For a related topic, see how to make a domain work with and without www, which explains the usual setups for the www name.

Limits and what to watch for

  • dig shows one path. The answer depends on the server you asked and what it has cached. A single query is a snapshot, not a verdict on what every user sees.
  • Your resolver may rewrite or filter. Some networks use resolvers that block or modify answers. If the answer from your default resolver looks strange, compare it with the answer from the domain's own name server.
  • Local settings can override DNS. Browsers have their own caches, and a hosts file on your computer can force a different address. dig bypasses both, so a mismatch between dig and the browser often points to the local machine.
  • UDP and TCP. Normal queries use UDP. Large answers or network rules may require TCP. If a query times out, try +tcp. If that works, a firewall or network device may be dropping large UDP responses.
  • ANY queries are unreliable. Many servers answer ANY queries with a reduced set or refuse them. Ask for specific types.
  • Output varies between versions. The comments and formatting differ between versions of dig. Do not build scripts that depend on exact wording; use +short or +noall +answer for stable output.
  • Be considerate. Querying a server you do not manage a few times is fine. Sending large volumes of queries can look like abuse and may be rejected.
  • dig does not check DNSSEC for you by default. It can display DNSSEC data when you ask for it, but interpreting a signed zone is a separate topic.

Troubleshooting with dig

What you see Likely meaning What to try
status: NXDOMAIN The name does not exist Check spelling and the zone where you created the record
NOERROR with ANSWER: 0 The name exists, but not for this record type Query the right type, or add the missing record
SERVFAIL The server could not complete the lookup Use +trace and check the name servers and delegation
REFUSED The server will not answer you You may be asking a server that does not serve you; use another
connection timed out No reply Check the server name, try +tcp, test another network
Old data with a falling TTL You are seeing a cached copy Ask the authoritative server and wait for the TTL
Different SERVER than expected You asked a different resolver Fix the command or the computer's DNS settings

When you are lost, use the same sequence each time: look up the NS records, ask an authoritative server for the record you care about, ask your own resolver, and compare. If the first answer is right and the second is old, you are waiting. If the first is wrong, the problem is in the zone itself.

Building a simple routine

You do not have to memorise everything. Keep a short list of commands, such as:

  1. dig +short example.com NS to find the name servers.
  2. dig @ns1.example.net example.com A +noall +answer to see the published record.
  3. dig example.com A +noall +answer to see what your resolver returns, with its TTL.
  4. dig +short example.com MX and dig +short example.com TXT when email or verification is the question.

Save the results with the date before and after any change. That way you can show exactly what changed and when. If you are looking after your own domain and want to see where its records are managed, the domains page is a good starting point.

Summary

dig prints the full DNS response, which makes it the most informative everyday tool for checking a domain. Read the status first, then the flags, then the answer section and its TTLs, and finally the SERVER line so you know whom you asked. Use +short or +noall +answer for tidy output, @server to separate published data from cached data, and +trace when you suspect a delegation problem. Remember that NOERROR with no answer is not the same as NXDOMAIN, that cached negative answers can delay a new record, and that one query is only a snapshot. When you are ready to review the records behind a domain of your own, the domains page shows where to continue.

Frequently asked questions

What is dig and how is it different from nslookup?

dig is a command-line tool that sends DNS queries and prints the full response, including status, flags, TTL values and the authority and additional sections. nslookup is simpler and hides most of those details, so dig is better for diagnosing problems.

How do I get just the answer from dig without all the extra text?

Add +short to the command, for example dig +short example.com A. To keep the formatted answer but drop the rest, use dig +noall +answer example.com. Both are good for scripts and quick checks.

What do NOERROR, NXDOMAIN and SERVFAIL mean in dig?

NOERROR means the query was answered normally. NXDOMAIN means the name does not exist. SERVFAIL means the server could not produce a valid answer. NOERROR with an empty answer section means the name exists but has no record of the type you asked for.

How do I query a specific DNS server with dig?

Put an at sign and the server before the name, for example dig @ns1.example.net example.com. Asking the domain's own name server shows the records as published, without a resolver cache.

What does dig +trace do?

It starts at the root servers and follows the chain of delegations down to the domain's name servers, printing each step. It helps you find where a lookup breaks, such as a wrong delegation at the registry.

About the author

Bob Kanokphon Thongdee, founder of XPASS VPN

Bob Kanokphon Thongdee

  • Founder of XPASS VPN
  • Co-founder of eSIMonline.asia
  • More than 7 years in online marketing
  • Founder of Cojourney Visa and Cojourney Travel

Ready to register your domain?

Search a name, compare extensions and pay once for the years you choose.

.com registration from $18.81 for the first year

Search domains

Keep reading

Domain & DNS Guides

How to Check DNS Records with nslookup

nslookup is a built-in tool for asking DNS what it knows about a name. This guide shows the commands, how to read the answers and what to do when they look wrong.

9 min read

Domain & DNS Guides

How to Make Your Domain Work With and Without www

Visitors type your domain both ways, so both must work. This guide covers choosing a preferred address, DNS records, redirects, SSL and testing.

9 min read

Domain & DNS Guides

How Long Does DNS Propagation Really Take?

DNS propagation is mostly a matter of caches expiring. See what controls the wait, how to check each layer, and how to plan changes so visitors notice nothing.

10 min read