DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

dig(ADMN)


dig -- send domain name query packets to name servers

Syntax

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 (DNS) servers. dig has two modes:

All query options are accessible from the command line.

The typical use of dig is:

dig @server domain query-type query-class

Options


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

If a domain name is specified, this will be resolved using the DNS resolver (BIND). 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 to indicate where the default name servers reside, so that server itself can be resolved. See resolver(SFF) for information about /etc/resolv.conf.


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

As an option, the user may set the environment variable LOCALRES to name a file which is to be used instead of /etc/resolv.conf. LOCALRES is specific to the dig resolver and is not referenced by the standard resolver. If the LOCALRES variable is not set or the specified file is not readable, then /etc/resolv.conf is used.


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 = address). The following types are 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 an authoritative server)
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 an authoritative server)
 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 be used to 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 query-class using the -c option (see below).


%ignored-comment
Use % to include an argument which is not 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


-dig-option
Use - to specify an option which affects the operation of dig. The following options are available:

-x dot-notation-address
A convenient form to specify inverse address mapping. Instead of:

dig 32.0.9.128.in-addr.arpa

you can use:

dig -x 128.9.0.32


-f file
The file for dig batch mode. The file contains a list of query specifications (dig command lines) which are to be executed sequentially. Lines beginning with ``;'' , ``#'' or a newline are ignored. Other options may still appear on 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. This can be used to keep two or more batch dig commands running roughly in synchronization. The default is zero.

-p port
Port number. Query a name server listening to a non-standard port number. The default is 53.

-P [ping-string]
After the query returns, execute a ping(ADMN) command for response time comparison via a call to the shell. The last three lines of statistics are printed for the command:

ping -s server_name 56 3

A different version of the ping command may be specified in ping_string.


-t query-type
Specify the type of query. This may be either an integer value to be included in the type field, or an abbreviation as discussed above (that is, mx = T_MX).

-c query-class
Specify the class of query. This may be either an integer value to be included in the class field, or an abbreviation as discussed above (that is, in = C_IN).

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


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

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


-envset
This flag only affects batch query runs. When this is specified on a line in a dig batch file, the dig environment -- after the arguments are parsed -- becomes the default environment for the duration of the batch file, or until the next line which specifies -envset is found.

-[no]stick
This flag only affects batch query runs. It specifies that the dig environment (as read initially or set by -envset is to be restored before each query (line) in a dig batch file. The default value of -nostick means that the dig environment does not stick, hence options specified on a single line in a dig batch file will remain in effect for subsequent lines: that is, they are not restored to the ``sticky'' default).

+query-option
Use + to specify an option to be changed in the query packet, or to change dig output specifics. Many of these are the same parameters accepted by nslookup(TC). If an option requires a parameter, the syntax is:

+keyword=value

Most keywords can be abbreviated. Parsing of the + option is very simplistic -- a value must not be separated from its keyword by white space. The following keywords are currently available:

Keyword Abbreviation Meaning (default)
[no]debug deb turn on/off debugging mode (deb)
[no]d2 nod2 turn on/off extra debugging mode (nod2)
[no]recurse rec use/don't use recursive lookup
retry=n ret set number of retries to n (4)
time=n ti set timeout length to n seconds
[no]ko   keep open option (implies vc) (noko)
[no]vc   use/don't use virtual circuit (novc)
[no]defname def use/don't use default domain name
[no]search sea use/don't use domain search list (sea)
domain=name do set default domain name to name
[no]ignore i ignore/don't ignore truncation errors (noi)
[no]primary pr use/don't use primary server (nopr)
[no]aaonly aa authoritative query only flag (noaa)
[no]sort sor sort resource records (nosor)
[no]cmd 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 information (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=n   set print flags to n, where n can be hex/octal/decimal
pfand=n   bitwise and print flags with n
pfor=n   bitwise or print flags with n

 Keyword       Abbreviation   Meaning (default)
 [no]debug     deb            turn on/off debugging mode (deb)
 [no]d2        nod2           turn on/off extra debugging mode
                              (nod2)
 [no]recurse   rec            use/don't use recursive lookup
 retry=n       ret            set number of retries to n (4)
 time=n        ti             set timeout length to n seconds
 [no]ko                       keep open option (implies vc) (noko)
 [no]vc                       use/don't use virtual circuit (novc)
 [no]defname   def            use/don't use default domain name
 [no]search    sea            use/don't use domain search list (sea)
 domain=name   do             set default domain name to name
 [no]ignore    i              ignore/don't ignore truncation errors
                              (noi)
 [no]primary   pr             use/don't use primary server (nopr)
 [no]aaonly    aa             authoritative query only flag (noaa)
 [no]sort      sor            sort resource records (nosor)
 [no]cmd       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 information (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=n                      set print flags to n, where n can be
                              hex/octal/decimal
 pfand=n                      bitwise and print flags with n
 pfor=n                       bitwise or print flags with n

The retry and time options affect the retransmission strategy used by the resolver(SLIB-osr5) 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(SLIB-osr5) library. As of BIND 4.9, BIND's resolver has been augmented to work properly with dig. Essentially, dig is a straight-forward (albeit not pretty) effort of parsing arguments and setting appropriate parameters. dig uses the resolver routines res_init, res_mkquery and res_send; it also accesses the _res structure.

Environment


LOCALRES
file to use in place of /etc/resolv.conf

LOCALDEF
default environment file

See also the explanation of the -envsav and -envset and -[no]stick options, above.

Files


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

./DiG.env
default save file for default options

See also

named(ADMN), nslookup(TC), resolver(SFF), resolver(SLIB-osr5)

RFC 1035

Notices

Author

Steve Hotz, hotz@isi.edu

Acknowledgements

dig uses functions from nslookup(TC) authored by Andrew Cherenson.

Limitations

dig has a serious case of ``creeping featurism'' -- the result of considering several potential uses during its development. It would probably benefit from a rigorous diet. Similarly, the print flags and granularity of the items they specify make evident their rather ad hoc genesis.

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


NOTE: Most of the common exit cases are handled.

This is particularly annoying when running in batch mode. If it exits abnormally (and is not caught), the entire batch aborts; when such an event is trapped, dig simply continues with the next query.


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005