Checking DNS from the command line: dig and nslookup, and how to read the answer

The short answer: dig and nslookup ask the DNS directly what it answers for a name. They are the quickest way to know whether a change has arrived, where your domain points and why something does not resolve. dig comes with Linux and Mac (on a VPS you may need to install the dnsutils or bind-utils package); nslookup also exists on Windows.

The commands used most

To see... dig nslookup
Where the site points dig +short A example.com nslookup example.com
Where the e-mail goes dig +short MX example.com nslookup -type=MX example.com
The TXT records (SPF, DMARC) dig +short TXT example.com nslookup -type=TXT example.com
The nameservers dig +short NS example.com nslookup -type=NS example.com
Asking one particular server dig @1.1.1.1 example.com nslookup example.com 1.1.1.1

The +short gives just the answer, without the rest of the text. Swap example.com for your domain. For a subdomain, write it in full: dig +short A shop.example.com.

How to read the full answer

Without +short, dig shows several sections. In dig example.com MX these parts matter:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR
;; ANSWER SECTION:
example.com. 14400 IN MX 10 mail.example.com.

Part What it says
status: NOERROR The question was answered. If there is an answer, it appears in “ANSWER SECTION”.
status: NXDOMAIN The name does not exist. See DNS_PROBE_FINISHED_NXDOMAIN.
status: SERVFAIL The server that answered could not get the answer (a broken zone, nameservers that do not respond or a DNSSEC problem).
The number after the name (14400) The TTL, in seconds: how long an answer may be kept.
NOERROR but no “ANSWER SECTION” The name exists, but has no record of that type.

Has a change arrived?

Ask your domain’s own server and a public server at the same time, and compare. First find the nameservers with dig +short NS example.com; then:
dig +short A example.com @ns1.of-your-nameservers.com
dig +short A example.com @1.1.1.1

If the first already shows the new value and the second still the old one, the change is right and only time (the TTL) needs to pass. If not even the first shows it, the record was not saved in the right place. See How long DNS changes take to propagate.

Mind the cache on your computer and your network. A browser can show the old site even with the right DNS. dig, unless you say otherwise, asks the DNS server configured on your computer, and that one also keeps answers. Asking with @1.1.1.1 or the nameserver itself avoids that mistake.
To just see the result without a command line, see How to check a domain DNS. And what the records mean: DNS records explained.

Does the DNS answer in a way you do not understand? Open a ticket with the domain and the text dig showed you.

Open a support ticket

SEE ALSO

How long DNS changes take to propagate

DNS_PROBE_FINISHED_NXDOMAIN: what it means and what to check

How to check a domain DNS

Nameservers: what they are and which ones to use with us

RECOMMENDED PRODUCT

Register your .co.mz domain

Secure your company name before someone else registers it. from 3.751,20 MT/yr

Search a domain
  • 0 Users Found This Useful
Was this answer helpful?