LightAtom

dig Command: DNS Lookups with Examples

dig is the most complete DNS tool built into macOS. Learn the commands you'll use every day and how to read its sections.

dig +short apple.com

Print only the answer: apple.com's IPv4 addresses.

intermediate10 minNeeds: Terminal

When to use it

Use dig when you need to see exactly what DNS returns: the records, their TTLs, which server answered and how long it took. It's the tool for checking DNS changes, debugging email records and comparing resolvers.

Steps

  1. Get a quick answer

    +short prints only the values, which is perfect for scripts and quick checks.
    dig +short apple.com
  2. Look up other record types

    Put the type after the name: A, AAAA, MX, TXT, NS, CNAME, SOA, CAA.
    dig github.com TXT +short
  3. Ask a specific resolver

    Use @server to compare answers, for example after a DNS change.
    dig apple.com @8.8.8.8
  4. Reverse lookup

    -x finds the host name for an IP address.
    dig -x 8.8.8.8 +short
  5. Follow the delegation from the root

    +trace queries the root, then .com, then the domain's own servers, showing each step. Useful when a domain's name servers are misconfigured.
    dig +trace apple.com

Output explained

; <<>> DiG 9.10.6 <<>> apple.com
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56678
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 9

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

;; ANSWER SECTION:
apple.com.		542	IN	A	17.253.144.10

;; AUTHORITY SECTION:
apple.com.		16592	IN	NS	a.ns.apple.com.

;; Query time: 12 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
  • status is the result: NOERROR (found), NXDOMAIN (doesn't exist), SERVFAIL (the resolver failed).
  • flags: qr = this is a response, rd = recursion desired, ra = recursion available. aa appears when the answer is authoritative.
  • ANSWER SECTION holds the records. The number after the name (542) is the remaining TTL in seconds.
  • AUTHORITY SECTION lists the name servers responsible for the domain.
  • Query time and SERVER tell you how fast and from which resolver the answer came.

Options and variations

FlagMeaningExample
+shortOnly the answer valuesdig +short apple.com AAAA
@serverQuery a specific DNS serverdig @9.9.9.9 apple.com
-x IPReverse lookup (PTR)dig -x 1.1.1.1
+traceFollow delegation from the root serversdig +trace example.com
+noall +answerShow only the answer section, with TTLsdig +noall +answer apple.com
+tcpQuery over TCP instead of UDPdig +tcp apple.com

Common errors

ErrorCauseFix
;; connection timed out; no servers could be reachedThe DNS server didn't answerTry @1.1.1.1; check network and DNS settings.
status: SERVFAILThe resolver couldn't complete the lookup (often DNSSEC)Try +cd to skip DNSSEC validation and compare; fix the domain's DNSSEC.
Empty ANSWER section with NOERRORThe name exists but has no record of that typeTry another type (A vs AAAA vs CNAME).

Do it in the app

LightAtom's connections view shows the domain and address of each connection your apps make, without running dig by hand.

Frequently asked questions

Is dig installed on a Mac?

Yes. macOS includes dig (version 9.10.6 on macOS 15), along with nslookup and host.

What is the difference between nslookup and dig?

dig prints the full DNS response, with TTLs, flags and every section, and is easier to script with +short. nslookup gives a simpler summary. Both query DNS the same way.

How do I see a record's TTL?

Run dig +noall +answer name. The number after the name is the TTL in seconds, counting down while the record sits in the resolver's cache.

How do I check if a DNS change has propagated?

Query several resolvers: dig +short name @1.1.1.1, @8.8.8.8 and @9.9.9.9. When they all return the new value, it's live for most users. The DNS propagation checker does this worldwide.

LightAtom team

The people who build LightAtom, a network monitor for macOS.