dig Command Reference: Flags, Usage & CI Examples
dig queries DNS records from the command line.
dig (from bind-utils/dnsutils) performs DNS lookups and shows the full query and answer. In CI it verifies that a service hostname resolves before a job tries to connect or deploy.
Common flags and usage
- dig <name>: full lookup with query details
- +short: print just the answer records
- A / AAAA / CNAME / MX / TXT: query a record type
- @<server>: query a specific resolver
- +trace: follow the delegation from the root
- -x <ip>: reverse lookup
Example
shell
dig +short db.internal.example.com
dig +short A api.example.com @1.1.1.1In CI
dig +short is the cleanest way to assert a hostname resolves before a deploy or connection step. Querying a specific resolver with @<server> helps debug split-horizon or private DNS that differs from the public answer.
Key takeaways
- dig performs DNS lookups with full query and answer detail.
- +short trims output to just the records, ideal for scripts.
- @<server> targets a specific resolver to debug private DNS.
Related guides
nslookup Command Reference: Usage & CI ExamplesReference for nslookup: querying A/MX/TXT records, specifying a server, the dig comparison, and a CI example…
getent Command Reference: Databases, Usage & CI ExamplesReference for getent: hosts, passwd, group, the NSS-aware lookup advantage, and a CI example that resolves a…
ping Command Reference: Flags, Usage & CI ExamplesReference for ping: -c, -W, -i, the ICMP-blocked caveat, and a CI example that checks basic host reachability…