dig(1) CLIX dig(1)
NAME
dig - Sends domain name query packets to name servers
SYNOPSIS
dig [@server] domain [query-type] [query-class] [+query-option] [-dig-
option] [%comment]
FLAGS
server Specifies the name server to which to send the query. The
server parameter can be either a 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.
Note that if a domain name is specified, this will be
resolved using the domain name system resolver (that is,
BIND). If your system does not support DNS, you must 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.
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 not referenced by the standard resolver). If the
LOCALRES variable is not set or the file is not readable,
then /etc/resolv.conf will be used.
domain Specifies the domain name for which you are requesting
information. Refer to the description for the -x dig option
for a convenient way to specify inverse address query.
query-type Specifies 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
See RFC 1035 for the complete list.
query-class Specifies the network class requested in the query. If
2/94 - Intergraph Corporation 1
dig(1) CLIX dig(1)
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.
Note that any can be used to specify a class and/or a type of
query. The dig command will parse the first occurrence of
any to mean the following:
query-type = T_ANY
To specify the following:
query-class = C_ANY
you must either specify any twice, or set the query-class
using the -c dig option (see below).
-dig-option Specifies an option that effects the operation of dig. The
following options are currently available (although not
guaranteed to be useful):
-x address Specifies in dot notation the inverse address
mapping. Instead of keying in
dig 32.0.9.128.in-addr.arpa
you can key in
dig -x 128.9.0.32
-f file Specifies file for dig batch mode. The file
contains a list of query specifications (dig
command lines) that are to be executed
successively. Lines beginning with a semi-colon
(;), a number sign (#), or backslash followed by
an n (\n) are ignored. Other options can still
appear on command line, and will be in effect for
each batch query.
-T time Specifies the time in seconds between the 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 is
zero.
-p port Specifies a port number. Queries a name server
2 Intergraph Corporation - 2/94
dig(1) CLIX dig(1)
listening to a non-standard port number. The
default is 53.
-P[ping-string]
Executes a ping command for response time
comparison after query returns. This rather
unelegantly makes a call to the shell. The last
three lines of statistics are printed for the
command:
ping -s server_name 56 3
If the optional ping-string is present, it
replaces ping -s in the shell command.
-t query-type
Specifies the type of query. May specify either
an integer value to be included in the type field
or use the abbreviated mnemonic as discussed
previously (for example, mx = T_MX).
-c query-class
Specifies the class of query. May specify either
an integer value to be included in the class
field or use the abbreviated mnemonic as
discussed previously (for example, in = C_IN).
-envsav Specifies that the dig environment (defaults,
print options, and so on), after all of the
arguments are parsed, should be saved to a file
to become the default environment. 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, timeouts, 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 DiG.env is created in
the current working directory.
Note that 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 file
exists and is readable, then the environment is
restored from this file before any arguments are
2/94 - Intergraph Corporation 3
dig(1) CLIX dig(1)
parsed.
-envset Affects only batch query runs. When -envset is
specified on a line in a dig batch file, the dig
environment after the arguments are parsed, and
becomes the default environment for the duration
of the batch file, or until the next line which
specifies -envset.
-[no]stick Affects only batch query runs. It specifies that
the dig environment (as read initially or set by
-envset switch) is to be restored before each
query (line) in a dig batch file. The default -
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 (for example, they are not
restored to the "sticky" default).
+query_option
Specifies a query_option to be changed in the query packet or
to change dig output specifics. Many of these are the same
parameters accepted by nslookup. If an option requires a
parameter, the form is 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:
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 trunc. 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 (RTT,etc) [st]
[no]Header (H) Print basic header [H]
4 Intergraph Corporation - 2/94
dig(1) CLIX dig(1)
[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=# Set print flags to # (# can be hex/octal/decimal)
pfand=# Bitwise and print flags with #
pfor=# Bitwise or print flags with #
The retry and time options affect the retransmission strategy
used by 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 that dig always uses a value of 1 for num_servers.
The pfset, pfand, and pfor keywords were included to make
manipulation of the various print options less tedious.
Below are the currently defined meanings for the various
print flag bits. They may be combined (ANDed) to achieve
various output formats.
PRF_STATS 0x0001 RTT, query & server host, date, msg size
PRF_CLASS 0x0004 Resource record class information
PRF_CMD 0x0008 dig command line echo
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 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
2/94 - Intergraph Corporation 5
dig(1) CLIX dig(1)
PRF_MIN 0xa930 Minimalistic dig settings for
(future) Automated server testing
When setting the print options, if you want to see
information other than statistics, you should choose to
examine the outgoing (0x1000), incoming (0x2000), or both
packets plus the specific sections of the packet in which you
are interested.
%comment 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. For example:
dig @128.9.0.32 %venera.isi.edu mx isi.edu
DESCRIPTION
The dig (domain information groper) command is a flexible command-line
tool which can be used to gather information from the Domain Name System
servers. The dig command has two modes: simple interactive mode, which
makes 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 most common and simple use of dig takes the following form:
dig @server domain query-type query-class
EXAMPLES
1. The following example queries the default name server for any domain
information about the node jhawk, which is in the same domain as the
node from which the command is being executed.
dig jhawk
The output from this example appears as follows:
; <<>> DiG 2.0 <<>> jhawk
;; ->>HEADER<<- opcode: QUERY , status: NOERROR, id: 6
;; flags: qr aa rd ra ; Ques: 1, Ans: 1, Auth: 0, Addit: 0
;; QUESTIONS:
;; jhawk.b30.graph.com, type = A, class = IN
;; ANSWERS:
jhawk.b30.graph.com. 86400 A 129.135.175.27
;; Sent 1 pkts, answer found in time: 16 msec
6 Intergraph Corporation - 2/94
dig(1) CLIX dig(1)
;; FROM: jhawk to SERVER: default -- 129.135.170.224
;; WHEN: Tue Aug 18 08:43:31 1992
;; MSG SIZE sent: 36 rcvd: 52
The header section provides status and flags of the reply. The
default domain b30.graph.com (as defined in the /etc/resolv.conf file)
is appended to the host jhawk (that was entered on the command line)
to form the question. The default query type is A (for address). The
question is asked of the default name server 129.135.170.224, as
defined in the /etc/resolv.conf file.
2. The following example queries the name server at 137.39.1.3 (instead
of the default server) for domain information about the node ampere in
the domain ecu.ukans.edu.
dig ampere.ece.ukans.edu @137.39.1.3 any
The output appears as follows:
; <<>> DiG 2.0 <<>> ampere.ece.ukans.edu @137.39.1.3 any
;; ->>HEADER<<- opcode: QUERY , status: NOERROR, id: 10
;; flags: qr aa rd ra ; Ques: 1, Ans: 1, Auth: 0, Addit: 0
;; QUESTIONS:
;; ampere.ece.ukans.edu, type = ANY, class = IN
;; ANSWERS:
ampere.ece.ukans.edu. 3600 A 129.237.116.1
;; Sent 1 pkts, answer found in time: 2466 msec
;; FROM: jhawk to SERVER: 137.39.1.3
;; WHEN: Tue Aug 18 08:58:26 1992
;; MSG SIZE sent: 38 rcvd: 54
The nameserver had only an A record, so that is the only information
provided.
FILES
/etc/resolv.conf Initial domain name and name server addresses.
LOCALRES File to use in place of /etc/resolv.conf.
LOCALDEF Default environment file.
NOTES
The dig command uses functions from nslookup.
The dig command requires a slightly modified version of the BIND resolver
library to gather count and time statistics. Otherwise, it is
straightforward (albeit not pretty) effort of parsing arguments and
2/94 - Intergraph Corporation 7
dig(1) CLIX dig(1)
setting appropriate parameters. The dig command uses resolver routines
res_init(), res_mkquery(), and res_send(), as well as accessing _res
structure. Compiling dig with the standard resolver library is possible,
but will change the output format, make the print options meaningless, and
not gather RTT and packet count statistics.
CAUTIONS
Changing /etc/resolv.conf will affect the standard resolver library and,
potentially, several programs which use it.
DIAGNOSTICS
If the dig request was not successful, an error message is printed.
Possible errors include the following:
⊕ Time-out errors occur when the server does not respond to a request
after a certain amount of time. The error message will appear as
follows:
;; res_send to server default -- 137.39.1.3: Connection timed out
⊕ Depending on the query type, "no information" errors can occur if there
is no information available even though the query was in the correct
format. In the header the "Ans" count will be zero.
⊕ "Non-existent domain" errors occur if the domain or host does not
exist. In the header, status will be NXDOMAIN and the SQA of the root
DNS server will be returned. Often the root server returned will be
NS.NIC.DDN.MIL.
EXIT VALUES
The dig command does not consistently exit nicely (with appropriate
status) when a problem occurs somewhere in the resolver (though 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.
RELATED INFORMATION
Commands: named(8), nslookup(1)
Functions: resolver(3)
Files: resolv.conf(4)
8 Intergraph Corporation - 2/94