DIG(1)

๐Ÿ’– NAME ๐Ÿ’–

DIG(1) from BIND 9 is the manual page for dig, the DNS lookup utility. Thatโ€™s the whole name section, but stay with me, bestie, because this tool is lowkey iconic. ๐Ÿฆ‹

๐Ÿ“œ SYNOPSIS ๐Ÿ“œ

Hereโ€™s the shape of the thing:

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] [queryopt...]

dig [-h]

dig [global-queryopt...] [query...]

๐ŸŒธ DESCRIPTION ๐ŸŒธ

Okay so dig is this flexible tool for interrogating DNS name servers. It does DNS lookups and shows you the answers that come back from the name server(s) you queried. Most DNS admins use dig to troubleshoot DNS problems because itโ€™s flexible, easy to use, and the output is clear. Other lookup tools tend to have less functionality than dig โ€” not to be shady, itโ€™s just facts. ๐Ÿ’…

Even though dig is normally used with command-line arguments, it also has a batch mode where it reads lookup requests from a file. If you give it the -h option, it prints a brief summary of its command-line arguments and options. The BIND 9 implementation of dig lets you issue multiple lookups from the command line. Slay.

Unless you tell it 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. No cap.

When you give no command-line arguments or options, dig performs an NS query for "." (the root). Iconic default behavior, honestly. ๐Ÿ‘‘

You can set per-user defaults for dig via ${HOME}/.digrc. That file gets 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. Very important for script girlies. ๐ŸŽ€

The IN and CH class names overlap with the IN and CH top-level domain names. So 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. Donโ€™t let the overlap catch you off guard. ๐ŸŒธ

๐Ÿงš SIMPLE USAGE ๐Ÿงš

A typical invocation of dig looks like:

dig @server name type

where:

  • server โ€” is the name or IP address of the name server to query. This can be an IPv4 address in dotted-decimal notation or an IPv6 address in colon-delimited notation. When the supplied server argument is a hostname, dig resolves that name before querying that name server.

If no server argument is provided, dig consults /etc/resolv.conf; if an address is found there, it queries the name server at that address. If either of the -4 or -6 options are in use, then only addresses for the corresponding transport are tried. If no usable addresses are found, dig sends the query to the local host. The reply from the name server that responds is displayed. ๐Ÿซถ

  • name โ€” is the name of the resource record that is to be looked up.
  • type โ€” indicates what type of query is required โ€” ANY, A, MX, SIG, etc. type can be any valid query type. If no type argument is supplied, dig performs a lookup for an A record.

โœจ OPTIONS โœจ

Okay bestie, hereโ€™s the option menu. Every flag matters, so donโ€™t skip the boring-looking ones. ๐Ÿ‘‘

  • -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 keyfile. Key files can be generated using tsig-keygen. When using TSIG authentication with dig, the name server that is queried needs to know the key and algorithm that is being used. In BIND, this is done by providing appropriate key and server statements in named.conf for TSIG and by looking up the KEY record in zone data for SIG(0).
  • -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. The incremental zone transfer contains all changes made to the zone since the serial number in the zoneโ€™s SOA record was N. All resource record types can be expressed as TYPEnn, where nn is the number of the type. If the resource record type is not supported in BIND 9, the result is displayed as described in RFC 3597.
  • -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. When the -x option is used, there is no need to provide the name, class, and type arguments. 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. IPv6 addresses are looked up using nibble format under the IP6.ARPA domain.
  • -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. ๐Ÿ™ˆ

๐ŸŒˆ QUERY OPTIONS ๐ŸŒˆ

dig gives you a bunch of query options that affect how lookups are made and how results are displayed. Some set or reset flag bits in the query header, some decide which sections of the answer get printed, and others determine the timeout and retry strategies. Literally the control panel. โœจ

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; for example, +cd is equivalent to +cdflag. Query options are order sensitive. The query options are:

  • +aaflag, +noaaflag โ€” This option is a synonym for +aaonly, +noaaonly.
  • +aaonly, +noaaonly โ€” This option sets the aa flag in the query.
  • +additional, +noadditional โ€” This option displays [or does not display] the additional section of a reply. The default is to display it.
  • +adflag, +noadflag โ€” This option sets [or does not set] the AD (authentic data) bit in the query. This requests the server to return whether all of the answer and authority sections have been validated as secure, according to the security policy of the server. AD=1 indicates that all records have been validated as secure and the answer is not from a OPT-OUT range. AD=0 indicates that some part of the answer was insecure or not validated. This bit is set by default.
  • +all, +noall โ€” This option sets or clears all display flags.
  • +answer, +noanswer โ€” This option displays [or does not display] the answer section of a reply. The default is to display it.
  • +authority, +noauthority โ€” This option displays [or does not display] the authority section of a reply. The default is to display it.
  • +badcookie, +nobadcookie โ€” This option retries the lookup with a new server cookie if a BADCOOKIE response is received.
  • +besteffort, +nobesteffort โ€” This option attempts to display the contents of messages which are malformed. The default is to not display malformed answers.
  • +bufsize[=B] โ€” This option sets the UDP message buffer size advertised using EDNS0 to B bytes. The maximum and minimum sizes of this buffer are 65535 and 0, respectively. +bufsize restores the default buffer size.
  • +cd, +cdflag, +nocdflag โ€” This option sets [or does not set] the CD (checking disabled) bit in the query. This requests the server to not perform DNSSEC validation of responses.
  • +class, +noclass โ€” This option displays [or does not display] the CLASS when printing the record.
  • +cmd, +nocmd โ€” This option toggles the printing of the initial comment in the output, identifying the version of dig and the query options that have been applied. This option always has a global effect; it cannot be set globally and then overridden on a per-lookup basis. The default is to print this comment.
  • +coflag, +co, +nocoflag, +noco โ€” This option sets [or does not set] the CO (Compact denial of existence Ok) EDNS bit in the query. If set, it tells servers that Compact Denial of Existence responses are acceptable when replying to queries. The default is +nocoflag.
  • +comments, +nocomments โ€” toggles whether dig shows some comment lines in the output, like the info about the packet header, the OPT pseudosection, and the names of the response section ๐Ÿ’ฌ. The default is to print these comments. Other types of comments in the output are not affected by this option โ€” those are controlled by other command-line switches, including +cmd, +question, +stats, and +rrcomments โœจ.
  • +cookie=####, +nocookie โ€” sends [or does not send] a COOKIE EDNS option, with an optional value ๐Ÿช. Replaying a COOKIE from a previous response lets the server identify a previous client. The default is +cookie. Also, +cookie is set when +trace is set, to better emulate the default queries from a nameserver.
  • +crypto, +nocrypto โ€” toggles the display of cryptographic fields in DNSSEC records ๐Ÿ”. Those field contents are unnecessary for debugging most DNSSEC validation failures, and removing them makes common failures easier to see. The default is to display the fields. When omitted, theyโ€™re replaced by the string [omitted] or, in the DNSKEY case, the key ID is displayed as the replacement, e.g. [ key id = value ].
  • +defname, +nodefname โ€” this option is deprecated ๐Ÿซ  and is treated as a synonym for +search, +nosearch.
  • +dns64prefix, +nodns64prefix โ€” looks up IPV4ONLY.ARPA AAAA and prints any DNS64 prefixes found ๐Ÿงš.
  • +dnssec, +do, +nodnssec, +nodo โ€” requests that DNSSEC records be sent by setting the DNSSEC OK (DO) bit in the OPT record in the additional section of the query ๐Ÿ‘‘.
  • +domain=somename โ€” sets the search list to contain the single domain somename, as if specified in a domain directive in /etc/resolv.conf, and enables search list processing as if the +search option were given ๐ŸŒธ.
  • +edns[=#], +noedns โ€” specifies the EDNS version to query with. Valid values are 0 to 255. Setting the EDNS version causes an EDNS query to be sent. +noedns clears the remembered EDNS version. EDNS is set to 0 by default โœจ.
  • +ednsflags[=#], +noednsflags โ€” sets the must-be-zero EDNS flags bits (Z bits) to the specified value ๐ŸŽ€. Decimal, hex, and octal encodings are accepted. Setting a named flag (e.g. DO, CO) is silently ignored. By default, no Z bits are set.
  • +ednsnegotiation, +noednsnegotiation โ€” enables/disables EDNS version negotiation ๐Ÿค. By default, EDNS version negotiation is enabled.
  • +ednsopt[=code[:value]], +noednsopt โ€” specifies the EDNS option with code point code and an optional payload of value as a hexadecimal string ๐Ÿ”ฅ. code can be either an EDNS option name (for example, NSID or ECS) or an arbitrary numeric value. +noednsopt clears the EDNS options to be sent.
  • +expire, +noexpire โ€” sends an EDNS Expire option โณ.
  • +fail, +nofail โ€” indicates that named should try [or not try] the next server if a SERVFAIL is received ๐Ÿ’€. The default is to not try the next server, which is the reverse of normal stub resolver behavior.
  • +fuzztime[=value], +nofuzztime โ€” lets you specify the signing time when generating signed messages ๐Ÿ•ฐ๏ธ. If a value is specified, itโ€™s the seconds since 00:00:00 January 1, 1970 UTC, ignoring leap seconds. If no value is specified, 1646972129 (Fri 11 Mar 2022 04:15:29 UTC) is used. The default is +nofuzztime, and the current time is used.
  • +header-only, +noheader-only โ€” sends a query with a DNS header without a question section ๐Ÿ™ˆ. The default is to add a question section. The query type and query name are ignored when this is set.
  • +https[=value], +nohttps โ€” indicates whether to use DNS over HTTPS (DoH) when querying name servers ๐ŸŒˆ. When this option is in use, the port number defaults to 443. The HTTP POST request mode is used when sending the query. If value is specified, itโ€™s used as the HTTP endpoint in the query URI; the default is /dns-query. So, for example, dig @example.com +https uses the URI https://example.com/dns-query.
  • +https-get[=value], +nohttps-get โ€” similar to +https, except that the HTTP GET request mode is used when sending the query ๐Ÿฆ‹.
  • +https-post[=value], +nohttps-post โ€” same as +https ๐Ÿ’–.
  • +http-plain[=value], +nohttp-plain โ€” similar to +https, except that HTTP queries are sent over a non-encrypted channel ๐Ÿ˜ฌ. When this option is in use, the port number defaults to 80 and the HTTP request mode is POST.
  • +http-plain-get[=value], +nohttp-plain-get โ€” similar to +http-plain, except that the HTTP request mode is GET ๐Ÿ“.
  • +http-plain-post[=value], +nohttp-plain-post โ€” same as +http-plain โญ.
  • +identify, +noidentify โ€” shows [or does not show] the IP address and port number that supplied the answer, when the +short option is enabled ๐Ÿ‘€. If short form answers are requested, the default is not to show the source address and port number of the server that provided the answer.
  • +idn, +noidn โ€” enable or disable IDN processing ๐ŸŒ. By default, IDN is enabled for input query names, and for display when the output is a terminal. You can also turn off digโ€™s IDN processing by setting the IDN_DISABLE environment variable.
  • +ignore, +noignore โ€” ignores [or does not ignore] truncation in UDP responses instead of retrying with TCP ๐Ÿ™…. By default, TCP retries are performed.
  • +keepalive, +nokeepalive โ€” sends [or does not send] an EDNS Keepalive option ๐Ÿ’“.
  • +keepopen, +nokeepopen โ€” keeps [or does not keep] the TCP socket open between queries, and reuses it rather than creating a new TCP socket for each lookup ๐Ÿ”. The default is +nokeepopen.
  • +multiline, +nomultiline โ€” prints [or does not print] records, like the SOA records, in a verbose multi-line format with human-readable comments ๐Ÿ“. The default is to print each record on a single line to facilitate machine parsing of the dig output.
  • +ndots=D โ€” sets the number of dots (D) that must appear in name for it to be considered absolute ๐ŸŽฏ. The default value is that defined using the ndots statement in /etc/resolv.conf, or 1 if no ndots statement is present. Names with fewer dots are interpreted as relative names, and are searched for in the domains listed in the search or domain directive in /etc/resolv.conf if +search is set.
  • +nsid, +nonsid โ€” when enabled, includes an EDNS name server ID request when sending a query ๐Ÿท๏ธ.
  • +nssearch, +nonssearch โ€” when this option is set, dig attempts to find the authoritative name servers for the zone containing the name being looked up, and displays the SOA record that each name server has for the zone ๐Ÿ‘‘. Addresses of servers that did not respond are also printed.
  • +onesoa, +noonesoa โ€” when enabled, prints only one (starting) SOA record when performing an AXFR ๐ŸŒ€. The default is to print both the starting and ending SOA records.
  • +opcode=value, +noopcode โ€” when enabled, sets (restores) the DNS message opcode to the specified value ๐Ÿง . The default value is QUERY (0).
  • +padding=value โ€” pads the size of the query packet using the EDNS Padding option to blocks of value bytes ๐Ÿงธ. For example, +padding=32 causes a 48-byte query to be padded to 64 bytes. The default block size is 0, which disables padding; the maximum is 512. Values are ordinarily expected to be powers of two, such as 128; however, this is not mandatory. Responses to padded queries may also be padded, but only if the query uses TCP or DNS COOKIE.
  • +proxy[=src_addr[#src_port]-dst_addr[#dst_port]], +noproxy โ€” when this option is set, dig adds PROXYv2 headers to the queries ๐Ÿ›ฐ๏ธ. When source and destination addresses are specified, the headers contain them and use the PROXY command. That means, for the remote peer, the queries were sent on behalf of another node, and the PROXYv2 header reflects the original connection endpoints. The default source port is 0 and destination port is 53. For encrypted DNS transports, to prevent accidental information leakage, encryption is applied to the PROXYv2 headers: the headers are sent right after the handshake process has been completed ๐Ÿ”. For plain DNS transports, no encryption is applied to the PROXYv2 headers. If the addressees are omitted, PROXYv2 headers that use the LOCAL command set are added instead. For the remote peer, that means the queries were sent on purpose without being relayed, so the real connection endpoint addresses must be used.
  • +proxy-plain[=src_addr[#src_port]-dst_addr[#dst_port], +noproxy-plain โ€” the same as +[no]proxy, but instructs dig to send PROXYv2 headers ahead of any encryption, before any handshake messages are sent ๐Ÿ“จ. That makes dig behave exactly how it is described in the PROXY protocol specification, but not all software expects such behaviour. Please consult the software documentation to find out if you need this option. (For example, dnsdist expects encrypted PROXYv2 headers sent over TLS when encryption is used, while HAProxy and many other software packages expect plain ones.) For plain DNS transports, the option is effectively an alias for the +[no]proxy described above.
  • +qid=value โ€” specifies the query ID to use when sending queries ๐Ÿ†”.
  • +qr, +noqr โ€” toggles the display of the query message as it is sent ๐Ÿ“ค. By default, the query is not printed.
  • +question, +noquestion โ€” toggles the display of the question section of a query when an answer is returned โ“. The default is to print the question section as a comment.
  • +raflag, +noraflag โ€” sets [or does not set] the RA (Recursion Available) bit in the query ๐Ÿšฉ. The default is +noraflag. This bit is ignored by the server for QUERY.
  • +rdflag, +nordflag โ€” literally just a synonym situation for +recurse, +norecurse. Same energy, different flag name. ๐Ÿ’…
  • +recurse, +norecurse โ€” toggles the RD (recursion desired) bit in the query. This bit is set by default, which means dig normally sends recursive queries. Recursion is automatically disabled when the +nssearch or +trace query option is used. No cap. โœจ
  • +retry=T โ€” sets the number of times to retry UDP and TCP queries to the server to T, instead of the default 2. Unlike +tries, this does not include the initial query. ๐ŸŽ€
  • +rrcomments, +norrcomments โ€” toggles the display of per-record comments in the output (for example, human-readable key information about DNSKEY records). The default is not to print record comments unless multiline mode is active. ๐Ÿ™ˆ
  • +search, +nosearch โ€” uses (or does not use) the search list defined by the searchlist or domain directive in resolv.conf, if any. The search list is not used by default. ๐Ÿฆ‹

ndots from resolv.conf (default 1), which may be overridden by +ndots, determines whether the name is treated as relative and hence whether a search is eventually performed. iykyk.

  • +short, +noshort โ€” toggles whether a terse answer is provided. The default is to print the answer in a verbose form. Heads up: this option always has a global effect; it cannot be set globally and then overridden on a per-lookup basis. ๐ŸŒธ
  • +showbadcookie, +noshowbadcookie โ€” toggles whether to show the message containing the BADCOOKIE rcode before retrying the request or not. The default is to not show the messages. ๐Ÿ’€
  • +showbadvers, +noshowbadvers โ€” toggles whether to show the message containing the BADVERS rcode before retrying the request or not. The default is to not show the messages. ๐Ÿ’€
  • +showsearch, +noshowsearch โ€” performs (or does not perform) a search showing intermediate results. ๐Ÿ”
  • +split=W โ€” splits long hex- or base64-formatted fields in resource records into chunks of W characters (where W is rounded up to the nearest multiple of 4). +nosplit or +split=0 causes fields not to be split at all. The default is 56 characters, or 44 characters when multiline mode is active. ๐ŸŽ€
  • +stats, +nostats โ€” toggles the printing of statistics: when the query was made, the size of the reply, etc. The default behavior is to print the query statistics as a comment after each lookup. ๐Ÿ“Š
  • +subnet=addr[/prefix-length], +nosubnet โ€” sends (or does not send) an EDNS CLIENT-SUBNET option with the specified IP address or network prefix. slay, subnetting. ๐ŸŒ

dig +subnet=0.0.0.0/0, or simply dig +subnet=0 for short, sends an EDNS CLIENT-SUBNET option with an empty address and a source prefix-length of zero, which signals a resolver that the client's address information must not be used when resolving this query.

  • +tcflag, +notcflag โ€” sets (or does not set) the TC (TrunCation) bit in the query. The default is +notcflag. This bit is ignored by the server for QUERY. ๐Ÿซถ
  • +tcp, +notcp โ€” indicates whether to use TCP when querying name servers. The default behavior is to use UDP unless a type any or ixfr=N query is requested, in which case the default is TCP. AXFR queries always use TCP. To prevent retry over TCP when TC=1 is returned from a UDP query, use +ignore. ๐Ÿ”ฅ
  • +timeout=T โ€” sets the timeout for a query to T seconds. The default timeout is 5 seconds. An attempt to set T to less than 1 is silently set to 1. โณ
  • +tls, +notls โ€” indicates whether to use DNS over TLS (DoT) when querying name servers. When this option is in use, the port number defaults to 853. ๐Ÿ”
  • +tls-ca[=file-name], +notls-ca โ€” enables remote server TLS certificate validation for DNS transports relying on TLS. Certificate authorities certificates are loaded from the specified PEM file (file-name). If the file is not specified, the default certificates from the global certificates store are used. ๐ŸŽ€
  • +tls-certfile=file-name, +tls-keyfile=file-name, +notls-certfile, +notls-keyfile โ€” these options set the state of certificate-based client authentication for DNS transports relying on TLS. Both certificate chain file and private key file are expected to be in PEM format. Both options must be specified at the same time. ๐Ÿ—๏ธ
  • +tls-hostname=hostname, +notls-hostname โ€” makes dig use the provided hostname during remote server TLS certificate verification. Otherwise, the DNS server name is used. This option has no effect if +tls-ca is not specified. ๐ŸŒˆ
  • +trace, +notrace โ€” toggles tracing of the delegation path from the root name servers for the name being looked up. Tracing is disabled by default. When tracing is enabled, dig makes iterative queries to resolve the name being looked up. It follows referrals from the root servers, showing the answer from each server that was used to resolve the lookup. ๐Ÿ‘‘

If @server is also specified, it affects only the initial query for the root zone name servers.

+dnssec is set when +trace is set, to better emulate the default queries from a name server.

Note that the delv +ns option can also be used for tracing the resolution of a name from the root (see delv).

  • +tries=T โ€” sets the number of times to try UDP and TCP queries to the server to T, instead of the default 3. If T is less than or equal to zero, the number of tries is silently rounded up to 1. ๐Ÿ”
  • +ttlid, +nottlid โ€” displays (or does not display) the TTL when printing the record. โฑ๏ธ
  • +ttlunits, +nottlunits โ€” displays (or does not display) the TTL in friendly human-readable time units of s, m, h, d, and w, representing seconds, minutes, hours, days, and weeks. This implies +ttlid. ๐Ÿ•ฐ๏ธ
  • +unknownformat, +nounknownformat โ€” prints all RDATA in unknown RR type presentation format (RFC 3597). The default is to print RDATA for known types in the type's presentation format. ๐Ÿ“œ
  • +vc, +novc โ€” uses (or does not use) TCP when querying name servers. This alternate syntax to +tcp is provided for backwards compatibility. The vc stands for "virtual circuit." ๐Ÿ”Œ
  • +yaml, +noyaml โ€” when enabled, this option prints the responses (and, if +qr is in use, also the outgoing queries) in a detailed YAML format. ๐Ÿงš
  • +zflag, +nozflag โ€” sets (or does not set) the last unassigned DNS header flag in a DNS query. This flag is off by default. ๐Ÿšฉ

๐ŸŽ€ MULTIPLE QUERIES ๐ŸŽ€

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. bestie, it's a whole group chat of queries. ๐Ÿ’–

In this case, each query argument represents an individual query in the command-line syntax described above. Each consists of any of the standard options and flags, the name to be looked up, an optional query type and class, and any query options that should be applied to that query. โœจ

A global set of query options, which should be applied to all queries, can also be supplied. These global query options must precede the first tuple of name, class, type, options, flags, and query options supplied on the command line. Any global query options (except +cmd and +short options) can be overridden by a query-specific set of query options. For example:

dig +qr www.isc.org any -x 127.0.0.1 isc.org ns +noqr

shows how dig can be used from the command line to make three lookups: an ANY query for www.isc.org, a reverse lookup of 127.0.0.1, and a query for the NS records of isc.org. A global query option of +qr is applied, so that dig shows the initial query it made for each lookup. The final query has a local query option of +noqr which means that dig does not print the initial query when it looks up the NS records for isc.org. three queries, one command line, zero chill. ๐Ÿ’…


๐Ÿ’– RETURN CODES ๐Ÿ’–

dig return codes are:

  • 0 โ€” DNS response received, including NXDOMAIN status. ๐Ÿซถ
  • 1 โ€” Usage error. ๐Ÿ™ˆ
  • 8 โ€” Couldn't open batch file. ๐Ÿ˜ญ
  • 9 โ€” No reply from server. ๐Ÿ’€
  • 10 โ€” Internal error. ๐Ÿซ 

๐Ÿฆ‹ FILES ๐Ÿฆ‹

  • /etc/resolv.conf
  • ${HOME}/.digrc

your config besties. ๐Ÿ“


โœจ EXAMPLES โœจ

Only display the IP address(es) for example.com:

dig +short example.com

Query the nameserver f.gtld-servers.net for example.com:

dig @f.gtld-servers.net example.com

Look up the TXT record for example.com:

dig txt example.com

Look up the hostname for an IP with reverse DNS:

dig -x 192.0.2.1

Display a much shorter output with just the name, record type, TTL, and value for each answer:

dig +noall +answer example.com

run them, bestie, they're iconic. ๐ŸŒˆ


๐ŸŒˆ SEE ALSO ๐ŸŒˆ


๐Ÿ’€ BUGS ๐Ÿ’€

ngl, there are probably too many query options. ๐Ÿ˜ญ That's the bug. That's it. iconic, honestly. ๐Ÿ’€


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Internet Systems Consortium. ๐Ÿ‘‘


2026, Internet Systems Consortium. ๐ŸŽ€


That's the whole page, bestie! This edition is from BIND 9.20.29, dated 2026-09-11. mwah ๐Ÿ’‹

๐Ÿ“ฆ where this page comes from