SpunkArt
Command line and project setup

How to look up DNS records yourself

DNS turns a name such as example.com into the addresses and settings computers need. You do not need a website to inspect it. Two commands, dig and nslookup, show every record, and this page explains how to read what they print.

Record types you will meet

TypeHoldsTypical use
AAn IPv4 addressPoints a name at a server
AAAAAn IPv6 addressThe same, for IPv6
CNAMEAnother nameAn alias, such as www pointing at a host provider name
MXA mail server name and a priorityWhere email for the domain is delivered
TXTFree textDomain verification, SPF and DMARC email policies
NSName server namesWhich servers are authoritative for the domain
SOAZone detailsPrimary server, serial number and timers
CAACertificate authority namesWhich authorities may issue certificates for the domain

Using dig

dig ships with macOS and most Linux systems (on Debian and Ubuntu it is in the dnsutils or bind9-dnsutils package). The basic form is dig name type:

dig example.com A
dig example.com MX +short
dig www.example.com CNAME
dig example.com TXT
dig @1.1.1.1 example.com A     # ask a specific resolver
dig +trace example.com         # follow the chain from the root servers

A trimmed answer section looks like this (the address is a documentation example):

;; ANSWER SECTION:
example.com.     3600    IN    A    192.0.2.10

Read it left to right: the name, the TTL in seconds, the class (IN for internet), the type, and the value. The TTL is how long resolvers may cache the answer. Here 3600 seconds is one hour. +short drops everything except the values, which is handy in scripts.

Using nslookup or PowerShell

nslookup is available on Windows, macOS and Linux:

nslookup example.com
nslookup -type=mx example.com
nslookup example.com 8.8.8.8

The last form sends the query to the resolver at 8.8.8.8. A “Non-authoritative answer” label just means the reply came from a cache, which is normal. In PowerShell, Resolve-DnsName example.com -Type MX gives tidier output.

A troubleshooting routine

  1. Ask your normal resolver: dig example.com A +short. Note the answer.
  2. Ask two public resolvers with @. If they disagree with yours, you are looking at caching.
  3. Find the authoritative servers: dig example.com NS +short.
  4. Ask one of them directly: dig @ns1.provider.example example.com A. This is the source of truth; if it is wrong, fix the record at your DNS host.
  5. If it is right, wait out the old TTL. Caches update once their copy expires.

“Propagation” is really caching

A DNS change is not pushed around the world. Each resolver keeps its cached copy until the TTL runs out, then asks again. If a record had a TTL of 86,400 seconds, some resolvers may show the old value for up to a day. Before a planned move, lower the TTL to something like 300 seconds, wait for the old TTL to pass, make the change, and raise it again afterwards.

Common mistakes

  • A CNAME at the bare domain. The standards do not allow a CNAME next to other records at the zone apex. Many DNS hosts offer a flattening or ALIAS feature instead.
  • Two SPF records. A domain should have only one TXT record that starts with v=spf1. Merge them.
  • Forgetting the trailing dot. In zone files, a name without a final dot gets the zone name appended, so mail.example.com can become mail.example.com.example.com.
  • Testing only from your own machine. Your computer and browser cache answers too. Flush them or query another resolver.

Questions

Why does this page not have a lookup box?

A real lookup has to query DNS servers over the network. This site keeps every page self-contained, so it explains the commands instead. They are free and built into most systems.

What does NXDOMAIN mean?

The name does not exist in DNS at all. Check the spelling and whether the domain is registered and delegated.