Black Friday: 60% off yearly plans with code BF2026, until November 30. See the deal

Learn

dig command: how to query DNS records with examples

dig (domain information groper) queries DNS servers from the command line: dig example.com returns the A record, dig example.com MX another type, and dig @1.1.1.1 example.com picks the server. Add +short for just the answer or +trace to follow the delegation from the root.

The short answer
  • Syntax: dig [@server] name [type] [+options]. Default type is A.
  • In the answer section, the number before IN is the remaining TTL.
  • +trace shows which server in the chain returned the problem.
Try the dns lookupFree, live, no signup

Which dig options are worth knowing?

Common dig usage
CommandWhat it does
dig example.comLooks up the A record using the resolver in /etc/resolv.conf
dig example.com MXLooks up another record type (AAAA, NS, TXT, SOA, CAA, SRV)
dig @1.1.1.1 example.comAsks a specific DNS server
dig example.com +shortPrints only the answer values
dig example.com +noall +answerPrints only the answer section, with TTLs
dig +trace example.comFollows delegation from the root servers down
dig -x 8.8.8.8Reverse lookup (PTR) for an IP address

Option behavior from the dig man page. dig comes with the BIND utilities; on Windows use WSL or install them, or use nslookup.

How do you read dig output?

Illustrative output for a documentation domain (192.0.2.0/24 is reserved)
$ dig example.com A
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4711
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

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

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

;; Query time: 24 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)

What do the parts mean?

  1. 01

    status

    NOERROR means success, NXDOMAIN means the name does not exist, SERVFAIL means the server could not complete the lookup.

  2. 02

    flags

    qr = response, rd = recursion desired, ra = recursion available, aa = authoritative answer. If aa is missing the answer came from a cache.

  3. 03

    ANSWER SECTION

    Name, remaining TTL in seconds, class IN, type and value. Repeat the query and watch the TTL count down to confirm caching.

  4. 04

    SERVER line

    Which resolver answered. Use @server to compare resolvers or query the authoritative server directly.

How do you verify a DNS change with dig?

  • dig NS example.com +short to find the authoritative nameservers
  • dig @ns1.dnshost.example example.com A +short to read the record with no cache involved
  • dig @1.1.1.1 example.com A and dig @8.8.8.8 example.com A to compare public resolvers
  • dig +trace example.com to find where delegation points to the wrong servers
  • dig example.com A +noall +answer twice to see the TTL count down

Which record types does dig handle that nslookup struggles with?

CAA

dig example.com CAA works, while the Windows nslookup tested here rejected CAA as an unknown type.

DNSSEC data

dig +dnssec shows RRSIG records, and dig DNSKEY and DS show the keys.

Delegation path

dig +trace shows the root, TLD and authoritative steps in one command.

When is dig better than a web tool?

Scripts

dig +short output is easy to parse in shell scripts and cron jobs.

Specific servers

You can query one authoritative server at a time, even before the change has spread.

Private networks

It queries the resolver your machine uses, including internal DNS that web tools cannot reach.

Common questions

What is the dig command?

dig is a command-line DNS query tool from the BIND software suite. It sends a query to a DNS server and prints the full response, including the question, answer, authority and additional sections.

How do I use dig to look up an MX record?

Run dig example.com MX. Add +short to see only the priorities and mail server hostnames. To bypass your default resolver add @1.1.1.1 or an authoritative nameserver name.

What does dig +trace do?

It makes dig do the resolution itself, starting at the root servers and following each referral down to the authoritative nameserver. It shows exactly which servers were asked and what each one returned.

Is dig available on Windows?

Not by default. Windows includes nslookup. You can run dig inside WSL, or install the BIND tools for Windows. For quick checks the web based DNS lookup tool gives the same record data.

What does dig +short show?

It prints only the answer values, one per line, such as an IP address or a list of mail servers, with no headers, TTL or flags. It suits scripts and quick checks but hides details you need for debugging.

Watch your domains automatically

Aepto monitors expiry, DNS, SSL and uptime for every domain you own and alerts you when something changes. Free for 3 domains.