Sample output
93.184.215.14
One line, one IP. That is where example.com resolves right now, according to your default nameserver. If you expected a different address, or no address at all, you have found the problem.
When you would reach for it
You changed a DNS record and want to know whether the change has propagated. A deploy failed because the app cannot reach an internal service by hostname. A colleague says “the site is down” and you need to separate a DNS problem from a server problem in under five seconds.
Gotchas
digqueries your system’s default resolver (usually whatever is in/etc/resolv.conf). That resolver may have a cached answer. To bypass it, query an authoritative server directly:dig +short example.com @8.8.8.8.- A CNAME answer returns the alias, not the IP. Run
dig +shortagain on the returned hostname, or usedig +traceto follow the full chain from root servers. - On Alpine and minimal Docker images,
digis not installed by default. Install it withapk add bind-tools, or usenslookupwhich ships withbusybox.
Variants
$ dig +short example.com MX
Query mail exchange records instead of A records
$ dig +short example.com @1.1.1.1
Ask Cloudflare’s resolver instead of your default, useful for checking propagation
$ dig example.com +trace
Follow the delegation chain from root servers to authoritative nameserver, showing every hop. Useful when you suspect a caching layer is returning a stale record