dig(1M) dig(1M)
NAME
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.
Files
/etc/resolv.conf initial domain name and name server
addresses
default save file for default options
Environment Variables
LOCALRES file to use in place of /etc/resolv.conf
LOCALDEF default environment file
USAGE
The dig tool has two modes:
simple interactive mode which makes a single query
batch mode which executes a query for each in a list of
several query lines
All query options are accessible from the command line.
Basic Arguments
The simple use of dig takes the following form:
dig @server domain query-type query-class
where:
server
may be 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 that, 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
Copyright 1994 Novell, Inc. Page 1
dig(1M) dig(1M)
is a server at your disposal somewhere, all that is
required is that /etc/resolv.conf be present and
indicate where the default name servers reside, so that
server itself can be resolved. See resolv.conf(4) for
information on /etc/resolv.conf.
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 if the file is
not readable, then /etc/resolv.conf will be used.
domain
is the domain name for which you are requesting
information. For a convenient way to specify an inverse
address query, see the description of the -x option.
query-type
is 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 an authoritative server)
txt T_TXT arbitrary number of strings (not yet supported by BIND)
See RFC 1035 for the complete list of types.
query-class
is 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
See RFC 1035 for the complete list of classes.
Note that any can be used to specify a class and/or a
type of query; dig will parse the first occurrence of
any to mean query-type = T_ANY. To specify query-class
Copyright 1994 Novell, Inc. Page 2
dig(1M) dig(1M)
= C_ANY you must either specify any twice, or set the
query-class using the -c option (see below).
Other Arguments
%ignored-comment
"%" is used 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
-dig-option
- is used to specify an option which affects the
operation of dig. The following options are currently
available (although not guaranteed to be useful):
-x dot-notation-address
is 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
is 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
is the 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 sync. The default value is zero.
-p port
is the port number. It is used to query a name
server listening to a non-standard Port Number.
The default value is 53.
-P[ping-string]
after the query returns, executes a ping(1M)
command for a response time comparison. This
Copyright 1994 Novell, Inc. Page 3
dig(1M) dig(1M)
rather unelegantly makes a call to the shell.
If the option -Pping-string is present, it will
replace ping -q in the shell command.
The last three lines of statistics will be printed
for the command:
ping -q -s 56 -c 3 server_name
-t query-type
specifies the type of query. This 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
specifies the class of query. This 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
is a flag that specifies that, after all of the
arguments are parsed, the dig environment
(defaults, print options, and so on) 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 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 that 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
Copyright 1994 Novell, Inc. Page 4
dig(1M) dig(1M)
will be restored from this file before any
arguments are parsed.
-envset
is a flag that affects 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
is a flag that affects 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
+ is used to 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(1M). If an option requires a parameter, the
format will be as follows:
+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:
Copyright 1994 Novell, Inc. Page 5
dig(1M) dig(1M)
Keyword Abbrev. Meaning (default)
___________________________________________________________________
nodebug deb turn on/off debugging mode (deb)
nod2 turn on/off extra debugging mode (nod2)
norecurse rec use/don't use recursive lookup (rec)
retry=n ret set number of retries to n (4)
time=n ti set timeout length to n seconds (4)
noko keep open option; implies vc (noko)
novc use/don't use virtual circuit (novc)
nodefname def use/don't use default domain name (def)
nosearch sea use/don't use domain search list (sea)
domain=NAME do set default domain name to NAME
noignore i ignore/don't ignore truncation errors (noi)
noprimary pr use/don't use primary server (nopr)
noaaonly aa authoritative query only flag (noaa)
nosort sor sort resource records (nosor)
nocmd echo parsed arguments (cmd)
nostats st print query statistics (RTT, etc) (st)
noHeader H print basic header (H)
noheader he print header flags (he)
nottlid tt print TTLs (tt)
nocl print class info (nocl)
noqr print outgoing query (noqr)
noreply rep print reply (rep)
noques qu print question section (qu)
noanswer an print answer section (an)
noauthor au print authoritative section (au)
noaddit 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 (n can be hexadecimal
/octal/decimal)
pfand=n bitwise "and" print flags with n
pfor=n bitwise "or" print flags with n
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
Copyright 1994 Novell, Inc. Page 6
dig(1M) dig(1M)
Note that dig always uses a value of 1 for num_servers.
The pfset, pfand, and pfor options have been included to
make the manipulation of the various print options less
tedious. Below is a list of the currently defined
meanings for the various print flag bits which may be
combined (ANDed) to achieve various output formats.
PRF_STATS 0x0001 RTT, query and server host, date, message size
PRF_CLASS 0x0004 Resource record class information
PRF_CMD 0x0008 echo the dig command line
PRF_QUES 0x0010 questions section
PRF_ANS 0x0020 answers section
PRF_AUTH 0x0040 authoritative section
PRF_ADD 0x0080 additional records section
PRF_HEAD1 0x0100 RR section headers & counts
PRF_HEAD2 0x0200 packet header flags
PRF_TTLID 0x0400 Resource record Time-to-Live (ttl)
PRF_HEADX 0x0800 basic header
PRF_QUERY 0x1000 outgoing query packet
PRF_REPLY 0x2000 reply packet
PRF_SORT 0x8000 sort various response sections
PRF_DEF 0x2ff9 default dig settings
PRF_ZONE 0x24f9 default setting for zone transfer
PRF_MIN 0xa930 minimalistic dig settings for (future) automated
server testing
When setting the print options and if you want to see
information other than the statistics, you should choose
to examine the outgoing (0x1000) packet type, the
incoming (0x2000) packet type, or both packet types, as
well as the specific sections of the packet(s) of
particular interest to you.
General Considerations
The dig tool requires a slightly modified version of the BIND
resolver(3N) library to gather count and time statistics.
Otherwise, it is a straight-forward (but not pretty) effort of
parsing arguments and setting appropriate parameters. The dig
tool uses resolver routines res_init, res_mkquery, 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.
Copyright 1994 Novell, Inc. Page 7
dig(1M) dig(1M)
dig does not exit consistently with an appropriate status when
a problem occurs somewhere in the resolver. This becomes
particularly annoying 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 simply will continue with the
next query.
Warnings
Changing /etc/resolv.conf will affect the standard resolver
library and potentially several programs which use it.
REFERENCES
named(1M), nslookup(1M), ping(1M), resolver(3N),
resolv.conf(4)
RFC 1035
Copyright 1994 Novell, Inc. Page 8