Advanced
Searching inHow-to guides
How to search
  • Type the task in your own words (find port, open firewall, disk full) or paste an error message in quotes.
  • Choose "Quick answer" to see only the commands, or an area to stay in one field.
  • "two words" finds the exact phrase.
  • Plain words find names, texts and examples.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search
Try:

How-to 16Network · DNS

How to check the DNS records of a domain

A new site does not open, email goes to spam, a certificate request fails, or "it works for me but not for the customer". Many of these are DNS problems. dig shows exactly what a DNS server answers: the records, the TTL, which server answered, and the whole chain from the root. This how-to shows the records you check most at work, how to ask a specific server, and how to find out if a change has spread yet.

  • 5 Lessons
  • 6 Commands

$ run as a normal user# run as root (or with sudo)

16.1

The quick answer

dig +short shop.example.com A
203.0.113.20
dig +short shop.example.com AAAA
dig +short example.com MX
10 mail.example.com.
dig +short example.com TXT
dig +short example.com NS
dig +short -x 203.0.113.20

dig is in bind-utils (RHEL) or dnsutils / bind9-dnsutils (Ubuntu).

Commands in this lesson

16.2

Step by step

  1. Read a full answer (without +short) to see the TTL and the status:
dig shop.example.com A
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41922
;; ANSWER SECTION:
shop.example.com.   300   IN   A   203.0.113.20
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)

300 = the answer may be cached for 300 seconds. status is the first thing to read:

StatusMeaning
NOERROR + answerThe record exists.
NOERROR, no answerThe name exists, but not this record type.
NXDOMAINThe name does not exist (typo, or not created).
SERVFAILThe server could not answer: broken DNSSEC, the zone's servers do not answer.
REFUSEDThis server does not answer you (not open for recursion).
  1. The records you check most:
TypeUse
A / AAAAIPv4 / IPv6 address of a name.
CNAMEAlias to another name (www → shop.example.com).
MXMail servers for the domain.
TXTSPF (v=spf1), domain checks, DKIM (selector._domainkey), DMARC (_dmarc).
NSThe servers that are the source (authoritative) for the zone.
CAAWhich CAs may issue certificates (can block Let's Encrypt).
PTRReverse: IP → name (dig -x), important for mail servers.
  1. Ask the source directly — the authoritative server shows the new value at once, caches may still show the old one:
dig +short example.com NS
ns1.example-dns.net.
dig +short @ns1.example-dns.net shop.example.com A
dig +short @1.1.1.1 shop.example.com A
dig +short @8.8.8.8 shop.example.com A
  1. Follow the whole path from the root (when delegation or NS records are wrong):
dig +trace shop.example.com
  1. Email records in one go:
dig +short example.com TXT | grep spf
dig +short _dmarc.example.com TXT
dig +short s1._domainkey.example.com TXT
  1. What does this server use? Programs use the system resolver (and /etc/hosts), not always the same as dig:
getent hosts shop.example.com
resolvectl query shop.example.com

16.3

Check that it worked

After you changed a record: the authoritative server shows the new value at once; public resolvers (@1.1.1.1, @8.8.8.8) show it after the old TTL ends. Then test the service itself (curl -I https://shop.example.com).

Commands in this lesson

16.4

Common problems

ProblemCauseFix
Old IP still answered after the changeCaches keep the old answer until its TTL ends.Wait for the TTL. Next time lower the TTL (for example to 300) a day before the change.
dig is right, the server still uses the old IPAn /etc/hosts entry, or the local cache.getent hosts NAME; check /etc/hosts; resolvectl flush-caches.
SERVFAIL only on some resolversDNSSEC is broken (wrong DS record), or a name server is down.dig +dnssec, dig +trace; check the DS record at the registrar.
Different answers from different NS serversThe secondary did not get the zone update.Compare dig @ns1 / @ns2; check the SOA serial (dig +short SOA).
Let's Encrypt says CAA errorA CAA record does not list letsencrypt.org.Add 0 issue "letsencrypt.org" or remove the wrong CAA record.
Mails rejected or in spamMissing SPF/DKIM/DMARC or PTR.Check the TXT records and dig -x of the mail server IP.

16.5

Go further

1Why can a DNS change look done on one computer and not on another?

Resolvers cache the old answer until its TTL ends; ask the authoritative server to see the real value.

2What is the difference between NXDOMAIN and NOERROR with no answer?

NXDOMAIN = the name does not exist. NOERROR with no answer = the name exists but has no record of that type.

All commands in this chapter