$ run as a normal user# run as root (or with sudo)
The quick answer
Step by step
- 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:
| Status | Meaning |
|---|---|
NOERROR + answer | The record exists. |
NOERROR, no answer | The name exists, but not this record type. |
NXDOMAIN | The name does not exist (typo, or not created). |
SERVFAIL | The server could not answer: broken DNSSEC, the zone's servers do not answer. |
REFUSED | This server does not answer you (not open for recursion). |
- The records you check most:
| Type | Use |
|---|---|
A / AAAA | IPv4 / IPv6 address of a name. |
CNAME | Alias to another name (www → shop.example.com). |
MX | Mail servers for the domain. |
TXT | SPF (v=spf1), domain checks, DKIM (selector._domainkey), DMARC (_dmarc). |
NS | The servers that are the source (authoritative) for the zone. |
CAA | Which CAs may issue certificates (can block Let's Encrypt). |
PTR | Reverse: IP → name (dig -x), important for mail servers. |
- 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- Follow the whole path from the root (when delegation or NS records are wrong):
dig +trace shop.example.com- 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- What does this server use? Programs use the system resolver (and
/etc/hosts), not always the same asdig:
getent hosts shop.example.com
resolvectl query shop.example.comCheck 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).
Common problems
| Problem | Cause | Fix |
|---|---|---|
| Old IP still answered after the change | Caches 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 IP | An /etc/hosts entry, or the local cache. | getent hosts NAME; check /etc/hosts; resolvectl flush-caches. |
SERVFAIL only on some resolvers | DNSSEC 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 servers | The secondary did not get the zone update. | Compare dig @ns1 / @ns2; check the SOA serial (dig +short SOA). |
| Let's Encrypt says CAA error | A CAA record does not list letsencrypt.org. | Add 0 issue "letsencrypt.org" or remove the wrong CAA record. |
| Mails rejected or in spam | Missing SPF/DKIM/DMARC or PTR. | Check the TXT records and dig -x of the mail server IP. |
Go further
- Command pages: dig, host, nslookup, getent.
- Next how-tos: Get a free TLS certificate with Let's Encrypt, Test if a remote port is open, Run your own DNS zone with BIND.
- Your own DNS server: Install BIND. At work: BIND in daily use.
- Learn it: RH124 — DNS, RHCSA — Name resolution.
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.