OpenBSD manual page server

Manual Page Search Parameters

DIG(1) General Commands Manual DIG(1)

digDNS lookup utility

dig [@server] [-46hiuv] [-b sourceaddr[#port]] [-c class] [-f file] [-k keyfile] [-p port] [-q name] [-t type] [-x addr] [-y [hmac:]name:key] [name] [type] [class] [+queryopt ...]

The dig command is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name servers that were queried. Although dig is normally used with command line arguments, it also has a batch mode of operation for reading lookup requests from a file. When no command line arguments or options are given, dig will perform an NS query for '.' (the root).

A typical invocation of dig looks like:

dig @server [options] name type [class] [+queryopt]
@server
The name or IP address of the name server to query. When the argument is a hostname, dig resolves that name before querying that name server. If no server argument is provided, dig will try each of the servers listed in resolv.conf(5). If no usable addresses are found, dig will send the query to the local host. The reply from the name server that responds is displayed.
name
The name of the resource record that is to be looked up.
type
The type of query, as documented for -t. The default is A.
class
The query class, as documented for -c. The default is IN.
+queryopt
One or more query options, as documented in QUERY OPTIONS, below.

The options are as follows:

Use IPv4 only.
Use IPv6 only.
sourceaddr[#port]
Set the source IP address of the query, which is useful on machines with multiple interfaces. The sourceaddr 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>".
class
Set the query class. The default is IN; other classes are HS for Hesiod records and CH for Chaosnet records.
file
Batch mode: 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 they would be presented as queries to dig using the command-line interface.
Display a brief summary of command line arguments and options.
Do reverse IPv6 lookups using the obsolete RFC 1886 IP6.INT domain, which is no longer in use. Obsolete bit string label queries (RFC 2874) are not attempted.
keyfile
Sign queries using TSIG. The format of the keyfile is as follows:
key "keyname" {
	algorithm hmac;
	secret "base64-secret";
};

keyname is the name of the key, and base64-secret is the base64-encoded shared secret. hmac is the name of the key algorithm; valid choices are hmac-sha1, hmac-sha224, hmac-sha256, hmac-sha384, and hmac-sha512.

port
Send the query to a non-standard port on the server, instead of the default port 53. This option would be used to test a name server that has been configured to listen for queries on a non-standard port number.
name
The domain name to query. This is useful to distinguish the name from other arguments.
type
The resource record type to query. It 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 is required, set the type to IXFR=N. The incremental zone transfer will contain the 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 will be displayed as described in RFC 3597.

Print query times in microseconds instead of milliseconds.
Print the version number and exit.
addr
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 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 (but see also the -i option).
[hmac:]keyname:secret
Sign 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-sha1, hmac-sha224, hmac-sha256, hmac-sha384, and hmac-sha512. If hmac is not specified, the default is hmac-sha256.

NOTE: You should use the -k option and avoid 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 ps(1) or in a history file maintained by the user's shell.

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.

dig provides a number of query options which affect the way in which lookups are made and the results displayed. Some of these set or reset flag bits in the query header, some determine which sections of the answer get printed, and others determine the timeout and retry strategies.

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. The query options are:

[no]aaflag
A synonym for +[no]aaonly.
[no]aaonly
Set the "aa" flag in the query (off by default).
[no]additional
Display the additional section of a reply (on by default).
[no]adflag
Set the AD (authentic data) bit in the query (on by default). This requests the server to return whether all of the answer and authority sections have all 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 an OPT-OUT range. AD=0 indicates that some part of the answer was insecure or not validated.
[no]all
Set or clear all display flags.
[no]answer
Display the answer section of a reply (on by default).
[no]authority
Display the authority section of a reply (on by default).
[no]besteffort
Attempt to display the contents of messages which are malformed (on by default).
=#
Set the UDP message buffer size advertised using EDNS0 to # bytes. The maximum and minimum sizes of this buffer are 65535 and 0 respectively. Values outside this range are rounded up or down appropriately. Values other than zero will cause an EDNS query to be sent.
[no]cdflag
Set the CD (checking disabled) bit in the query (off by default). This requests the server to not perform DNSSEC validation of responses.
[no]class
Display the CLASS when printing the record (on by default).
[no]cmd
Print an initial comment identifying the version of dig and the query options that have been applied (on by default).
[no]comments
Display comment lines in the output (on by default).
[no]cookie[=value]
Send a COOKIE EDNS option, containing an optional value (off by default). Replaying a COOKIE from a previous response will allow the server to identify a previous client.

+cookie is automatically set when +trace is in use, to better emulate the default queries from a name server.

This option was formerly called +[no]sit (Server Identity Token). In BIND 9.10.0 through BIND 9.10.2, it sent the experimental option code 65001. This was changed to option code 10 in BIND 9.10.3 when the DNS COOKIE option was allocated.

The +[no]sit option is now deprecated, but has been retained as a synonym for +[no]cookie for backward compatibility within the BIND 9.10 branch.

[no]crypto
Display cryptographic fields in DNSSEC records (on by default). The contents of these field are unnecessary to debug most DNSSEC validation failures and removing them makes it easier to see the common failures. When omitted they are replaced by the string "[omitted]" or in the DNSKEY case the key id is displayed as the replacement, e.g. "[ key id = value ]".
[no]defname
Deprecated, treated as a synonym for +[no]search.
[no]dnssec
Request DNSSEC records be sent by setting the DNSSEC OK bit (DO) in the OPT record in the additional section of the query (off by default).
=name
Set the search list to contain the single domain name, as if specified in a domain directive in resolv.conf(5), and enable search list processing as if the +search option were given (off by default).
[no]edns[=#]
Use EDNS in the query (on by default). A version may also be specified, from 0 (the default) to 255. +noedns disables EDNS and clears the remembered version.
[=#]
Set the must-be-zero EDNS flags bits (Z bits) to the specified value (0 by default). Decimal, hex and octal encodings are accepted. Setting a named flag (e.g. DO) will silently be ignored.
[no]ednsnegotiation
Enable EDNS version negotiation (off by default).
[no]ednsopt[=code[:value]]
Specify EDNS option with code point code and optionally 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.
[no]expire
Send an EDNS Expire option (off by default).
[no]fail
Do not try the next server if you receive a SERVFAIL. This option is on by default, which is the reverse of normal stub resolver behavior.
[no]identify
Show the IP address and port number that supplied the answer (off by default). This option has no effect unless the +short option is enabled.
[no]idnout
Convert puny code on output. This version of dig does not support IDN.
[no]ignore
Ignore truncation in UDP responses. This option is off by default, which means truncated responses cause retrying with TCP.
[no]keepopen
Keep the TCP socket open between queries and reuse it. This option is off by default, which means that a new TCP socket is created for each lookup.
[no]multiline
Print records like the SOA records in a verbose multi-line format with human-readable comments. This option is off by default, which means that each record is printed on a single line to facilitate machine parsing of the dig output.
=#
Set the number of dots that have to appear in name to # for it to be considered absolute. The default value is that defined using the ndots statement in resolv.conf(5), or 1 if no ndots statement is present. Names with fewer dots are interpreted as relative names and will be searched for in the domains listed in the search or domain directive in resolv.conf(5) if +search is set.
[no]nsid
Include an EDNS name server ID request when sending a query (off by default).
[no]nssearch
Attempt to find the authoritative name servers for the zone containing the name being looked up and display the SOA record that each name server has for the zone (off by default).
[no]onesoa
Print only one (starting) SOA record when performing an AXFR. This option is off by default, which means that both the starting and the ending SOA records are printed.
[no]opcode=#
Set or restore the DNS message opcode to the specified value, which can be QUERY (the default), IQUERY, STATUS, NOTIFY, UPDATE, or an integer number in the range from 0 to 15.
[no]qr
Print the query as it is sent (off by default).
[no]question
Print the question section of a query as a comment when an answer is returned (on by default).
[no]rdflag
A synonym for +[no]recurse.
[no]recurse
Set the RD (recursion desired) bit in the query (on by default). Recursion is automatically disabled when the +nssearch or +trace query options are used.
=#
Set the number of times to retry UDP queries to server to #. The default is 2. Unlike +tries, this does not include the initial query.
[no]rrcomments
Display per-record comments in the output (for example, human-readable key information about DNSKEY records). The default is +rrcomments if +multiline mode is active or +norrcomments otherwise.
[no]search
Use the search list defined by the searchlist or domain directive in resolv.conf(5), if any (off by default). 'ndots' from resolv.conf(5) (default 1), which may be overridden by +ndots, determines if the name will be treated as relative or not and hence whether a search is eventually performed or not.
[no]short
Provide a terse answer (off by default).
[no]showsearch
Perform a search showing intermediate results (off by default).
[no]split=#
Split long hex- or base64-formatted fields in resource records into chunks of # characters (where # 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.
[no]stats
Print statistics: when the query was made, the size of the reply and so on (on by default).
[no]subnet=addr[/prefix]
Send an EDNS Client Subnet option with the specified IP address or network prefix (off by default).

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 be used when resolving this query.

[no]tcp
Use TCP when querying name servers (off by default). IXFR=N queries use TCP unless it is explicitly disabled with +notcp. AXFR queries always use TCP.
=#
Set the timeout for a query to # seconds. The default is 5 seconds for UDP and 10 seconds for TCP. An attempt to set # to less than 1 will result in a query timeout of 1 second being applied.
[no]trace
Trace the delegation path from the root name servers for the name being looked up (off by default).

When tracing is enabled, dig makes iterative queries to resolve the name being looked up. It will follow 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 also set when +trace is set to better emulate the default queries from a name server.

=#
Set the number of times to try UDP queries to server to #. The default is 3. If # is less than or equal to zero, the number of tries is silently rounded up to 1.
[no]ttlid
Display the TTL when printing the record (on by default).
[no]vc
Use TCP when querying name servers. This alternate syntax to +[no]tcp is provided for backwards compatibility. The "vc" stands for "virtual circuit".

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 represent 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 the +[no]cmd option) 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 could 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 will not print the initial query when it looks up the NS records for isc.org.

/etc/resolv.conf
Resolver configuration file.

host(1), resolv.conf(5)

P. Mockapetris, Domain Names - Implementation and Specification, RFC 1035, November 1987.

Internet Systems Consortium, Inc.

There are probably too many query options.

February 17, 2022 OpenBSD-7.4