DIG(1) BIND 9 DIG(1)
dig - DNS lookup utility
| Use Case | Command | Description |
|---|---|---|
| π Basic A record lookup | dig example.com | Look up A record for example.com |
| π Query specific server | dig @8.8.8.8 example.com | Query Google DNS for example.com |
| π Reverse lookup | dig -x 192.0.2.1 | Map IP address to hostname |
| π¦ Query specific type | dig example.com MX | Look up MX records |
| π Trace delegation path | dig +trace example.com | Follow DNS delegation from root |
| π Use DNS over HTTPS | dig @example.com +https | Use DoH to query |
| π Zone transfer | dig example.com AXFR | Request full zone transfer |
| β‘ Short output | dig example.com +short | Display only IP addresses |
dig [@server] [-b address] [-c class] [-f filename] [-k filename] [-m] [-p port#] [-q name]
[-t type] [-v] [-x addr] [-y [hmac:]name:key] [ [-4] | [-6] ] [name] [type] [class] [queryβ
opt...]
dig [-h]
dig [global-queryopt...] [query...]
dig is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried. Most DNS administrators use dig to troubleshoot DNS problems because of its flexibility, ease of use, and clarity of output.
Although dig is normally used with command-line arguments, it also has a batch mode of operation for reading lookup requests from a file. A brief summary of its command-line arguments and options is printed when the -h option is given. The BIND 9 implementation of dig allows multiple lookups to be issued from the command line.
Unless it is told to query a specific name server, dig tries each of the servers listed in /etc/resolv.conf. If no usable server addresses are found, dig sends the query to the local host.
When no command-line arguments or options are given, dig performs an NS query for "." (the root).
It is possible to set per-user defaults for dig via ${HOME}/.digrc. This file is read and any options in it are applied before the command-line arguments. The -r option disables this feature, for scripts that need predictable behavior.
The IN and CH class names overlap with the IN and CH top-level domain names. Either use the -t and -c options to specify the type and class, use the -q to specify the domain name, or use "IN." and "CH." when looking up these top-level domains.
A typical invocation of dig looks like:
dig @server name type
where:
-4 πβ¬οΈ This option indicates that only IPv4 should be used.
-6 πβ¬οΈ This option indicates that only IPv6 should be used.
-b address[#port] π This option sets the source IP address of the query. The address must be a valid address on one of the host's network interfaces, or "0.0.0.0" or "::". An optional port may be specified by appending #port.
-c class ποΈ This option sets the query class. The default class is IN; other classes are HS for Hesiod records or CH for Chaosnet records.
-f file π This option sets batch mode, in which dig reads a list of lookup requests to process from the given file. Each line in the file should be organized in the same way it would be presented as a query to dig using the command-line interface.
-h β Print a usage summary.
-k keyfile π This option tells dig to sign queries using TSIG or SIG(0) using a key read from the given file. Key files can be generated using tsig-keygen.
-m π§ This option enables memory usage debugging.
-p port π This option sends the query to a non-standard port on the server, instead of the default port 53. This option is used to test a name server that has been configured to listen for queries on a non-standard port number.
-q name π This option specifies the domain name to query. This is useful to distinguish the name from other arguments.
-r π« This option indicates that options from ${HOME}/.digrc should not be read. This is useful for scripts that need predictable behavior.
-t type π·οΈ This option indicates the resource record type to query, which can be any valid query type. If it is a resource record type supported in BIND 9, it can be given by the type mnemonic (such as NS or AAAA). The default query type is A, unless the -x option is supplied to indicate a reverse lookup. A zone transfer can be requested by specifying a type of AXFR. When an incremental zone transfer (IXFR) is required, set the type to ixfr=N.
-u β±οΈ This option indicates that print query times should be provided in microseconds instead of milliseconds.
-v βΉοΈ This option prints the version number and exits.
-x addr π This option sets simplified reverse lookups, for mapping addresses to names. The addr is an IPv4 address in dotted-decimal notation, or a colon-delimited IPv6 address. dig automatically performs a lookup for a name like 94.2.0.192.in-addr.arpa and sets the query type and class to PTR and IN respectively.
-y [hmac:]keyname:secret π This option signs queries using TSIG with the given authentication key. keyname is the name of the key, and secret is the base64-encoded shared secret. hmac is the name of the key algorithm; valid choices are hmac-md5, hmac-sha1, hmac-sha224, hmac-sha256, hmac-sha384, or hmac-sha512. If hmac is not specified, the default is hmac-md5; if MD5 was disabled, the default is hmac-sha256.
NOTE: β οΈ Only the -k option should be used, rather than the -y option, because with -y the shared secret is supplied as a command-line argument in clear text. This may be visible in the output from ps1 or in a history file maintained by the user's shell.
dig provides a number of query options which affect the way in which lookups are made and the results displayed. Each query option is identified by a keyword preceded by a plus sign (+). Some keywords set or reset an option; these may be preceded by the string no to negate the meaning of that keyword. Other keywords assign values to options, like the timeout interval. They have the form +keyword=value. Keywords may be abbreviated, provided the abbreviation is unambiguous.
+aaflag, +noaaflag β synonym for +aaonly, +noaaonly.
+aaonly, +noaaonly β sets the aa flag in the query.
+additional, +noadditional β displays [or does not display] the additional section of a reply. Default: display.
+adflag, +noadflag β sets the AD (authentic data) bit in the query. Default: set.
+all, +noall β sets or clears all display flags.
+answer, +noanswer β displays the answer section. Default: display.
+authority, +noauthority β displays the authority section. Default: display.
+badcookie, +nobadcookie β retries with a new server cookie if BADCOOKIE response received.
+besteffort, +nobesteffort β attempts to display malformed messages. Default: do not display.
+bufsize[=B] β sets the UDP message buffer size advertised using EDNS0 to B bytes. Default: restored.
+cd, +cdflag, +nocdflag β sets the CD (checking disabled) bit in the query. Requests server not to perform DNSSEC validation.
+class, +noclass β displays the CLASS when printing the record.
+cmd, +nocmd β toggles printing of the initial comment. Default: print.
+coflag, +co, +nocoflag, +noco β sets the CO (Compact denial of existence Ok) EDNS bit. Default: +nocoflag.
+comments, +nocomments β toggles display of some comment lines. Default: print.
+cookie=####, +nocookie β sends a COOKIE EDNS option. Default: +cookie.
+crypto, +nocrypto β toggles display of cryptographic fields in DNSSEC records. Default: display.
+defname, +nodefname β deprecated synonym for +search.
+dns64prefix, +nodns64prefix β lookup IPV4ONLY.ARPA AAAA and print any DNS64 prefixes.
+dnssec, +do, +nodnssec, +nodo β requests DNSSEC records by setting the DO bit.
+domain=somename β sets the search list to contain the single domain somename.
+dscp=value β obsolete, no effect.
+edns[=#], +noedns β specifies the EDNS version. Default: 0.
+ednsflags[=#], +noednsflags β sets the must-be-zero EDNS flags bits (Z bits).
+ednsnegotiation, +noednsnegotiation β enables/disables EDNS version negotiation. Default: enabled.
+ednsopt[=code[:value]], +noednsopt β specifies an EDNS option with code point code and optional payload.
+expire, +noexpire β sends an EDNS Expire option.
+fail, +nofail β indicates whether to try the next server if SERVFAIL is received. Default: not try.
+fuzztime[=value], +nofuzztime β allows signing time to be specified. Default: current time.
+header-only, +noheader-only β sends a query without a question section. Default: add question.
+https[=value], +nohttps β uses DNS over HTTPS (DoH). Port defaults to 443. HTTP POST mode.
+https-get[=value], +nohttps-get β similar to +https but uses HTTP GET.
+https-post[=value], +nohttps-post β same as +https.
+http-plain[=value], +nohttp-plain β similar to +https but over non-encrypted HTTP. Port defaults to 80.
+http-plain-get[=value], +nohttp-plain-get β similar to +http-plain but uses HTTP GET.
+http-plain-post[=value], +nohttp-plain-post β same as +http-plain.
+identify, +noidentify β shows the IP address and port number when +short is enabled.
+idnin, +noidnin β processes IDN domain names on input. Default: enabled when stdout is a tty.
+idnout, +noidnout β converts puny code on output. Default: enabled when stdout is a tty.
+ignore, +noignore β ignores truncation in UDP responses instead of retrying with TCP. Default: retry.
+keepalive, +nokeepalive β sends an EDNS Keepalive option.
+keepopen, +nokeepopen β keeps the TCP socket open between queries. Default: +nokeepopen.
+multiline, +nomultiline β prints records in verbose multi-line format. Default: single line.
+ndots=D β sets the number of dots (D) that must appear in name for it to be considered absolute. Default: from resolv.conf or 1.
+nsid, +nonsid β includes an EDNS name server ID request.
+nssearch, +nonssearch β attempts to find authoritative name servers and display SOA records.
+onesoa, +noonesoa β prints only one SOA record when performing an AXFR. Default: print both.
+opcode=value, +noopcode β sets the DNS message opcode. Default: QUERY (0).
+padding=value β pads the query packet using EDNS Padding option. Default: 0 (disabled).
+qid=value β specifies the query ID to use.
+qr, +noqr β toggles display of the query message. Default: not printed.
+question, +noquestion β toggles display of the question section. Default: print as comment.
+raflag, +noraflag β sets the RA (Recursion Available) bit. Default: +noraflag.
+rdflag, +nordflag β synonym for +recurse.
+recurse, +norecurse β toggles the RD (recursion desired) bit. Default: set.
+retry=T β sets the number of retries to T (default: 2).
+rrcomments, +norrcomments β toggles per-record comments. Default: not printed unless multiline.
+search, +nosearch β uses the search list from resolv.conf. Default: not used.
+short, +noshort β toggles terse answer. Default: verbose.
+showbadcookie, +noshowbadcookie β toggles showing BADCOOKIE message before retry. Default: not shown.
+showsearch, +noshowsearch β performs a search showing intermediate results.
+sigchase, +nosigchase β obsolete; use delv instead.
+split=W β splits long hex/base64 fields into chunks of W characters. Default: 56.
+stats, +nostats β toggles printing of statistics. Default: print.
+subnet=addr[/prefix-length], +nosubnet β sends an EDNS CLIENT-SUBNET option.
+tcflag, +notcflag β sets the TC (TrunCation) bit. Default: +notcflag.
+tcp, +notcp β indicates whether to use TCP. Default: UDP unless type any or ixfr.
+timeout=T β sets the timeout to T seconds. Default: 5.
+tls, +notls β uses DNS over TLS (DoT). Port defaults to 853.
+tls-ca[=file-name], +notls-ca β enables remote server TLS certificate validation.
+tls-certfile=file-name, +tls-keyfile=file-name, +notls-certfile, +notls-keyfile β sets certificate-based client authentication for TLS.
+tls-hostname=hostname, +notls-hostname β uses provided hostname during TLS certificate verification.
+topdown, +notopdown β obsolete; use delv instead.
+trace, +notrace β toggles tracing of the delegation path from the root. Default: disabled.
+tries=T β sets the number of tries to T (default: 3).
+trusted-key=#### β obsolete; use delv instead.
+ttlid, +nottlid β displays the TTL when printing the record.
+ttlunits, +nottlunits β displays TTL in human-readable units (s, m, h, d, w). Implies +ttlid.
+unknownformat, +nounknownformat β prints RDATA in unknown RR type presentation format.
+vc, +novc β synonym for +tcp (virtual circuit).
+yaml, +noyaml β prints responses in detailed YAML format.
+zflag, +nozflag β sets the last unassigned DNS header flag. Default: off.
The BIND 9 implementation of dig supports specifying multiple queries on the command line (in addition to supporting the -f batch file option). Each of those queries can be supplied with its own set of flags, options, and query options.
In this case, each query argument represents an individual query in the command-line syntax described above. A global set of query options, which should be applied to all queries, can also be supplied.
Example:
dig +qr www.isc.org any -x 127.0.0.1 isc.org ns +noqr
This makes three lookups: an ANY query for www.isc.org, a reverse lookup of 127.0.0.1, and a query for NS records of isc.org.
If dig has been built with IDN (internationalized domain name) support, it can accept and display non-ASCII domain names. To turn off IDN support, use the parameters +idnin and +idnout, or define the IDN_DISABLE environment variable.
There are probably too many query options.
Internet Systems Consortium
2026, Internet Systems Consortium
9.18.39-0ubuntu0.22.04.4-Ubuntu 2025-08-13 DIG(1)
Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-14 02:42 @216.73.216.156
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)