dig(1Mtcp)


dig -- send domain name query packets to name servers

Synopsis

dig [ @ server ] domain [ query_type ] [ query_class ]
[ +query_option ] [ -dig_option ] [%comment ]

Description

The Domain Information Groper, dig, is a flexible command line tool which can be used to gather information from the Domain Name System servers. The dig tool has two modes: All query options are accessible from the command line.

The simple use of dig takes the following form:

dig @server domain query_type query_class

Arguments

dig takes the following arguments:

server
Either a domain name or a dot-notation Internet address. If this optional field is omitted, dig will attempt to use the default name server for your machine.

NOTE: If a domain name is specified, this will be resolved using the Domain Name System (DNS) resolver. If your system does not support DNS, you may have to specify a dot-notation address. Alternatively, if there is a server at your disposal somewhere, all that is required is that /etc/resolv.conf be present and that it indicate where the default name servers reside, so that server itself can be resolved. See resolv.conf(4tcp) for more information.

WARNING: Changing /etc/resolv.conf will affect the standard resolver library and potentially several programs which use it.

domain
The domain name for which you are requesting information. See the -x option for a convenient way to specify an inverse address query.

query_type
The type of information (DNS query type) that you are requesting. If omitted, the default is a (T_A = network-address). The following types will be recognized:

a T_A network address
any T_ANY all/any information about specified domain
mx T_MX mail exchanger for the domain
ns T_NS name servers
soa T_SOA zone of authority record
hinfo T_HINFO host information
axfr T_AXFR zone transfer (must ask authoritative server)
rp T_RP responsible person records
txt T_TXT arbitrary number of strings

 
 a         T_A         network address 
 any       T_ANY       all/any information about specified domain 
 mx        T_MX        mail exchanger for the domain 
 ns        T_NS        name servers 
 soa       T_SOA       zone of authority record 
 hinfo     T_HINFO     host information 
 axfr      T_AXFR      zone transfer (must ask authoritative server) 
 rp        T_RP        responsible person records 
 txt       T_TXT       arbitrary number of strings 
(See RFC 1035 for the complete list.)

query_class
The network class requested in the query. If omitted, the default is in (C_IN = Internet). The following classes are recognized:

in C_IN Internet class domain
any C_ANY all/any class information

 
 in        C_IN        Internet class domain 
 any       C_ANY       all/any class information 
(See RFC 1035 for the complete list.)

NOTE: any can specify a class and/or a type of query: dig parses the first occurrence of any to mean query_type = T_ANY. To specify query_class = C_ANY you must either specify any twice or set the query_class using the -c option (see below).

%comment
Use % to include an argument which should not be parsed. This may be useful if running dig in batch mode. Instead of resolving every @server-domain-name in a list of queries, you can avoid the overhead of doing so, but still have the domain name on the command line as a reference. For example:
dig  @128.9.0.32  %venera.isi.edu  mx isi.edu 

Options

dig understands the following options:

-x dot-notation-address
A convenient form to specify inverse address mapping: instead of dig 32.0.9.128.in-addr.arpa one can simply enter dig -x 128.9.0.32.

-f file
A file for dig batch mode: the file contains a list of query specifications (that is, dig command lines) which are to be executed sequentially. Lines beginning with ``;'', ``#'', or ``\n'' are ignored. Other options may still appear on the command line and will be in effect for each batch query.

-T time
Time in seconds between start of successive queries when running in batch mode; can be used to keep two or more batch dig commands running roughly in sync. The default value is zero.

-p port
Port number: query a name server listening to a non-standard port number; the default value is 53.

-P [ ping_string ]
After the query returns, execute a ping(1Mtcp) command for a response time comparison via a call to the shell. The default ping_string is ping -q -s 56 -c 3 server_name. A different version of the ping command may be specified in the ping_string.

-t query_type
Specify the type of query: may specify either an integer value to be included in the type field or use the abbreviated mnemonic as discussed above (that is, mx = T_MX).

-c query_class
Specify the class of query: may specify either an integer value to be included in the class field or use the abbreviated mnemonic as discussed above (that is, in = C_IN).

-envsav
This flag specifies that the dig environment (defaults, print options, etc.), -- after all of the arguments are parsed -- should be saved to a file to become the default environment. This will be useful if you do not like the standard set of defaults and if you do not want to include a large number of options whenever dig is used. The environment will consist of resolver state variable flags, timeout values, and numbers of allowable retry attempts, as well as of the flags detailing the dig output contents (see below). If the shell environment variable LOCALDEF is set to the name of a file, this is where the default dig environment will be saved. If not, the file DiG.env will be created in the current working directory.

NOTE: LOCALDEF is specific to the dig resolver and will not affect the operation of the standard resolver library.

Whenever dig is executed, it will look for ./DiG.env or for the file specified by the shell environment variable LOCALDEF. If such a file exists and if it is readable, then the environment will be restored from this file before any arguments are parsed.

-envset
This flag will affect batch query runs only. When -envset is specified on a line in a dig batch file, the dig environment following the arguments will be parsed; then these values will be used as the default environment for the duration of the batch file (or until the system finds another command line which specifies -envset).

-[no]stick
This flag will affect batch query runs only: it specifies that the dig environment (as read initially or set by the -envset switch) is to be restored before each query (line) in a dig batch file.

The default value -nostick means that the dig environment should not stick; hence options specified on a single line in a dig batch file will remain in effect for subsequent lines (that is, they will not be restored to the ``sticky'' default).

+query_option
Specify an option to be changed in the query packet or to change some dig output specifics. Many of these are the same parameters accepted by nslookup(1Mtcp). If an option requires a parameter, the format is:

+keyword=value

Most keywords can be abbreviated. Parsing of the ``+'' options is very simplistic -- a value must not be separated from its keyword by white space.

The following keywords are currently available:

Keyword Abbrev Meaning [default]
[no]debug deb turn on/off debugging mode [deb]
[no]d2 turn on/off extra debugging mode [nod2]
[no]recurse rec use/do not use recursive lookup [rec]
retry=# ret set number of retries to # [4]
time=# ti set timeout length to # seconds [4]
[no]ko keep open option (implies vc) [noko]
[no]vc use/do not use virtual circuit [novc]
[no]defname def use/do not use default domain name [def]
[no]search sea use/do not use domain search list [sea]
domain=NAME do set default domain name to NAME
[no]ignore i ignore/do not ignore truncation errors [noi]
[no]primary pr use/do not use primary server [nopr]
[no]aaonly aa authoritative query only flag [noaa]
[no]sort sor sort resource records [nosor]
[no]cmd echo parsed arguments [cmd]
[no]stats st print query statistics [st]
[no]Header H print basic header [H]
[no]header he print header flags [he]
[no]ttlid tt print TTLs [tt]
[no]cl print class info [nocl]
[no]qr print outgoing query [noqr]
[no]reply rep print reply [rep]
[no]ques qu print question section [qu]
[no]answer an print answer section [an]
[no]author au print authoritative section [au]
[no]addit ad print additional section [ad]
pfdef set to default print flags
pfmin set to minimal default print flags
pfset=# set print flags to # (in hex/octal/decimal)
pfand=# bitwise ``and'' print flags with #
pfor=# bitwise ``or'' print flags with #

 
 Keyword          Abbrev   Meaning [default] 
 [no]debug        deb      turn on/off debugging mode [deb] 
 [no]d2                    turn on/off extra debugging mode [nod2] 
 [no]recurse      rec      use/do not use recursive lookup [rec] 
 retry=#          ret      set number of retries to # [4] 
 time=#           ti       set timeout length to # seconds [4] 
 [no]ko                    keep open option (implies vc) [noko] 
 [no]vc                    use/do not use virtual circuit [novc] 
 [no]defname      def      use/do not use default domain name [def] 
 [no]search       sea      use/do not use domain search list [sea] 
 domain=NAME      do       set default domain name to NAME 
 [no]ignore       i        ignore/do not ignore truncation errors [noi] 
 [no]primary      pr       use/do not use primary server [nopr] 
 [no]aaonly       aa       authoritative query only flag [noaa] 
 [no]sort         sor      sort resource records [nosor] 
 [no]cmd                   echo parsed arguments [cmd] 
 [no]stats        st       print query statistics [st] 
 [no]Header       H        print basic header [H] 
 [no]header       he       print header flags [he] 
 [no]ttlid        tt       print TTLs [tt] 
 [no]cl                    print class info [nocl] 
 [no]qr                    print outgoing query [noqr] 
 [no]reply        rep      print reply [rep] 
 [no]ques         qu       print question section [qu] 
 [no]answer       an       print answer section [an] 
 [no]author       au       print authoritative section [au] 
 [no]addit        ad       print additional section [ad] 
 pfdef                     set to default print flags 
 pfmin                     set to minimal default print flags 
 pfset=#                   set print flags to # (in hex/octal/decimal) 
 pfand=#                   bitwise ``and'' print flags with # 
 pfor=#                    bitwise ``or'' print flags with # 
The retry and time options will affect the retransmission strategy used by the resolver library when sending datagram queries. The algorithm is as follows:
for i = 0 to retry-1 
    for j = 1 to num_servers 
        send_query 
        wait((time * (2**i)) / num_servers) 
    end 
end 
NOTE: dig always uses a value of 1 for num_servers.

Details

The dig tool once required a slightly modified version of the BIND resolver(3N) library. BIND's resolver has (as of BIND 4.9) been augmented to work properly with dig. Essentially, dig is a straight-forward effort of parsing arguments and setting appropriate parameters. The dig tool uses resolver routines res_init, res_mkquery, and res_send; it also accesses the _res structure.

It is possible to compile dig with the standard resolver library, but this procedure will change the dig output format, make the dig print options meaningless, and not gather RTT and packet count statistics.

Environment variables

LOCALDEF
default environment file

Files

/etc/resolv.conf
initial domain name and name server addresses

./DiG.env
default save file for default options

References

named(1Mtcp), nslookup(1Mtcp), ping(1Mtcp), resolv.conf(4tcp), resolver(3N)

RFC 1035

Notices

dig does not exit consistently with an appropriate status when a problem occurs somewhere in the resolver.

NOTE: Most of the common exit cases are handled.

When running in batch mode: If dig exits abnormally -- and is not caught -- the entire batch will abort; when such an event is trapped, dig will simply continue with the next query.


30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.