Dig
(domain information groper) is a flexible command line tool
which can be used to gather information from the Domain
Name System servers.
Dig
has two modes: simple interactive mode
for a single query, and batch mode which executes a query for
each in a list of several query lines. All query options are
accessible from the command line.
The usual simple use of
dig
will take the form:
-ragged -offset indent-two
dig @ Ns Ar server domain query-type query-class
where:
-tag -width Fl
Ar 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:
If a domain name is specified, this will be resolved
using the domain name system resolver (i.e., 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 and indicate where the default
name servers reside, so that
server
itself can be resolved. See
resolver 5
for information on
/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
Ns Ev 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
will be used.
Ar domain
is the domain name for which you are requesting information.
See the
x
option (documented in the
OTHER OPTIONS
subsection of this section) for convenient way to specify inverse address
query.
Ar query-type
is the type of information (DNS query type) that
you are requesting. If omitted, the default is
Ar a
Dv T_A = Ar address .
The following types are recognized:
-hang -width "hinfo T_HINFO " -compact
Ar a\ \ \ \ \ \ Dv T_A
network address
Ar any\ \ \ \ Dv T_ANY
all/any information about specified domain
Ar mx\ \ \ \ \ Dv T_MX
mail exchanger for the domain
Ar ns\ \ \ \ \ Dv T_NS
name servers
Ar soa\ \ \ \ Dv T_SOA
zone of authority record
Ar hinfo\ \ Dv T_HINFO
host information
Ar axfr\ \ \ Dv T_AXFR
zone transfer (must ask an authoritative server)
Ar txt\ \ \ \ Dv T_TXT
arbitrary number of strings
(See RFC 1035 for the complete list.)
Ar query-class
is the network class requested in the query. If
omitted, the default is
Ar in
Dv C_IN = Ar Internet .
The following classes are recognized:
-tag -width "hinfo T_HINFO " -compact
Ar in\ \ \ \ \ Dv C_IN
Internet class domain
Ar any\ \ \ \ Dv C_ANY
all/any class information
(See RFC 1035 for the complete list.)
Note:
Ar Any
can be used to specify a
class
and/or a
type
of query.
Dig
will parse the first occurrence of
Ar any
to mean
query-type = Dv T_ANY .
To specify
query-class = Dv C_ANY ,
you must either specify
any
twice, or set
query-class
using the
c
option (see below).
-tag -width Fl
% Ns Ar ignored-comment
%
is used to included an argument that is simply 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, and still have the domain name on the command line
as a reference. Example:
-ragged -offset indent-two
dig @128.9.0.32 %venera.isi.edu mx isi.edu
Fl Aq Ar dig option
Fl
is used to specify an option which affects the operation of
dig .
The following options are currently
available (although not guaranteed to be useful):
-tag -width Fl
Fl x Ar dot-notation-address
Convenient form to specify inverse address mapping.
Instead of
Ic dig 32.0.9.128.in-addr.arpa ,
one can simply
Ic dig -x 128.9.0.32 .
Fl f Ar file
File for
dig
batch mode. The file contains a list
of query specifications
(
Ic dig
command lines) which are to be executed successively. Lines beginning with
; ,
# ,
or
\en
are ignored. Other options
may still appear on command line, and will be in
effect for each batch query.
Fl T Ar 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. Default is zero.
Fl p Ar port
Port number. Query a name server listening to a
non-standard port number. Default is 53.
Fl P Ns Bq Ar ping-string
After query returns, execute a
ping 8
command for response time comparison. This rather
unelegantly makes a call to the shell. The last
three lines of statistics is printed for the
command:
-ragged -offset indent-two
ping Fl s server_name 56 3
If the optional
Ar ping_string
is present, it
replaces
Ic ping Fl s
in the shell command.
Fl t Ar query-type
Specify type of query. May specify either an
integer value to be included in the type field
or use the abbreviated mnemonic as discussed
above (i.e.,
mx = Dv T_MX ) .
Fl c Ar query-class
Specify class of query. May specify either an
integer value to be included in the class field
or use the abbreviated mnemonic as discussed
above (i.e., in = C_IN).
Fl k Ar keydir:keyname
Sign the query with the TSIG key named keyname
that is in the directory keydir.
Fl 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 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 state
variable flags, timeout, and retries 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
Pa 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
Pa ./DiG.env
or the file specified by the shell environment variable
LOCALDEF .
If such file exists and is readable, then the
environment is restored from this file before any arguments are parsed.
Fl envset
This flag only affects batch query runs. When
Fl envset
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
Fl envset .
Xo
Op Cm no
Cm stick
This flag only affects batch query runs.
It specifies that the
dig
environment (as read initially
or set by
Fl envset
switch) is to be restored before each query (line) in a
dig
batch file.
The default
Fl 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 (i.e. they are not restored to the
sticky
default).
+ Ns Aq Ar query-option
+
is used 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 8 .
If an option requires a parameter, the form is as follows:
-ragged -offset indent-two
+
Ar keyword
Op = Ns Ar 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]
-tag -width "[no]primary (ret) " -compact
Xo
Cm no
Cm debug\ \ \ \
Cm deb
turn on/off debugging mode
Cm deb
Xo
Cm no
Cm d2\ \ \ \ \ \ \ \ \ \
turn on/off extra debugging mode
Cm nod2
Xo
Cm no
Cm recurse\ \
Cm rec
use/don't use recursive lookup
Cm rec
Xo
retry= Ns Ar #
\ \ \ \ \
Cm ret
set number of retries to #
4
Xo
time= Ns Ar #
\ \ \ \ \ \
Cm ti
set timeout length to # seconds
4
Xo
Cm no
Cm ko
keep open option (implies vc)
Cm noko
Xo
Cm no
Cm vc
use/don't use virtual circuit
Cm novc
Xo
Cm no
Cm defname\ \
Cm def
use/don't use default domain name
Cm def
Xo
Cm no
Cm search\ \ \
Cm sea
use/don't use domain search list
Cm sea
Xo
domain= Ns Ar NAME\ \
Cm do
set default domain name to
NAME
Xo
Cm no
Cm ignore\ \ \
Cm i
ignore/don't ignore trunc. errors
Cm noi
Xo
Cm no
Cm primary\ \
Cm pr
use/don't use primary server
Cm nopr
Xo
Cm no
Cm aaonly\ \ \
Cm aa
authoritative query only flag
Cm noaa
Xo
Cm no
Cm cmd
echo parsed arguments
Cm cmd
Xo
Cm no
Cm stats\ \ \ \
Cm st
print query statistics
Cm st
Xo
Cm no
Cm Header\ \ \
Cm H
print basic header
Cm H
Xo
Cm no
Cm header\ \ \
Cm he
print header flags
Cm he
Xo
Cm no
Cm ttlid\ \ \ \
Cm tt
print TTLs
Cm tt
Xo
Cm no
Cm cl
print class info
Cm nocl
Xo
Cm no
Cm qr
print outgoing query
Cm noqr
Xo
Cm no
Cm reply\ \ \ \
Cm rep
print reply
Cm rep
Xo
Cm no
Cm ques\ \ \ \ \
Cm qu
print question section
Cm qu
Xo
Cm no
Cm answer\ \ \
Cm an
print answer section
Cm an
Xo
Cm no
Cm author\ \ \
Cm au
print authoritative section
Cm au
Xo
Cm no
Cm addit\ \ \ \
Cm ad
print additional section
Cm ad
Cm pfdef
set to default print flags
Cm pfmin
set to minimal default print flags
Cm pfset= Ns Ar #
set print flags to #
(# can be hex/octal/decimal)
Cm pfand= Ns Ar #
bitwise and print flags with #
Cm pfor= Ns Ar #
bitwise or print flags with #
The
retry
and
time
options affect the retransmission strategy used by the resolver
library when sending datagram queries. The algorithm is as follows:
-literal -offset indent
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
Li num_servers . )
Dig
once required a slightly modified version of the BIND
resolver 3
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
resolver 3
routines
res_init ,
res_mkquery ,
res_send
as well as accessing the
_res
structure.