Skip to content
Latchkey

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.1

In 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →