dig Look up DNS records
Asks a DNS server for the records of a domain name and prints the full answer. Use it to see where a name points, check mail settings, or find out whether a DNS change has taken effect. Use +short when you only want the answer.
Synopsis
dig [@server] name [type] [+option]...
Common options
| Option or form | What it does |
|---|---|
+short | Print only the answer values, one per line, with none of the surrounding detail |
@server | Ask this DNS server instead of your default one, for example @8.8.8.8 |
-t TYPE | Record type to look up, such as A, AAAA, MX, TXT, NS or CNAME. You can also write the type after the name |
-x ADDRESS | Reverse lookup: find the name for an IP address |
-p PORT | Query a DNS server on PORT instead of 53 |
+trace | Follow the lookup from the root servers down, to see where it goes wrong |
+noall +answer | Hide everything except the answer section, keeping the TTL and record type |
Examples
dig example.com
dig +short example.com
dig +short MX example.com
dig @192.0.2.53 example.com A
dig example.com TXT +noall +answer
dig -x 192.0.2.10 +short
Notes
- dig with no record type asks for the A record (IPv4 address). Ask for AAAA to see IPv6.
- The number before the record type in the answer is the TTL in seconds. It is how long resolvers may cache the answer, which explains why DNS changes take time to appear.
- @server goes before the name or anywhere in the arguments. It lets you compare your normal resolver with a public one when a name looks wrong.
- dig prints nothing with +short if the record does not exist. Drop +short to see the status, such as NXDOMAIN (the name does not exist).
- dig is installed on macOS. On some minimal Linux systems it is in a separate package, often called dnsutils or bind-utils.
See also
Last reviewed 2026-10-07.