dig
Networking
Usage
dig [@server] <name> [type]Asks a DNS server directly and shows the records as they come back; it bypasses /etc/hosts and the system cache, so the answer can differ from what the browser sees, and some distributions need dnsutils or bind-utils installed first.
Common flags
| Flag | Meaning |
|---|---|
| +short | Just the answer, one record per line. |
| @1.1.1.1 | Ask a specific resolver instead of the system one. |
| A / AAAA / MX / TXT / NS / CNAME | The record type goes last, with no dash. |
| +noall +answer | Trim the output to the answer section only. |
| -x <ip> | Reverse lookup, address to name. |
| +trace | Walk down from the root servers, which shows where a delegation breaks. |
| +ttlunits | Print TTLs as 1h30m instead of raw seconds. |
Examples
dig +short example.comThe A records, nothing else.
dig @1.1.1.1 example.com MX +noall +answerMail records straight from a public resolver.
dig -x 8.8.8.8 +shortWhich name that address claims.
When a connection fails, these narrow down how far it got — name not resolving, no route, or a blocked port.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does dig do?
Asks a DNS server directly and shows the records as they come back; it bypasses /etc/hosts and the system cache, so the answer can differ from what the browser sees, and some distributions need dnsutils or bind-utils installed first.
Q. How do I type it?
dig [@server] <name> [type] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
7 are listed here; the full set is in man dig. This command sits under Networking.
Related commands
man page: man dig