network
dig
Queries DNS servers for records and diagnostics. Preferred over nslookup for scripting and detailed troubleshooting.
dig [@server] [name] [type] [OPTIONS] Common flags
| Flag | Purpose |
|---|---|
| +short | Terse output -- just the answer values |
| +trace | Delegate-by-delegate resolution from the root |
| +noall | Reset display flags; combine with +answer, +stats, etc. |
| -x | Reverse lookup for an IP address |
| -t | Record type (e.g. A, AAAA, MX, TXT, NS, CNAME) |
| -p | Query a specific port |
Examples
dig example.com Standard A-record lookup
dig +short MX example.com Just the mail servers for a domain
dig @1.1.1.1 example.com AAAA Ask Cloudflare's resolver for IPv6 records
dig -x 8.8.8.8 +short Reverse-lookup an IP address
Gotcha
dig queries your system resolver by default; add @server to bypass caching and test against a specific nameserver.
Related commands
curl
Transfers data to or from a server across many protocols including HTTP, HTTPS, FTP, and SCP. The Swiss Army knife of ad-hoc HTTP requests.
ssh
Opens an encrypted shell session to a remote host. Also runs single remote commands and can tunnel arbitrary TCP ports.
rsync
Efficient file synchronizer that copies only the differences between source and destination. Works locally or over SSH.