The usual simple use of dig will take the form:
dig @server domain query-type query-class
where:
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 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 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.
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.)
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 will parse 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 "-c" option (see below).
dig @128.9.0.32 %venera.isi.edu mx isi.edu
ping -s server_name 56 3
If the optional "ping string" is present, it replaces "ping -s" in the shell command.
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 file exists and is readable, then the environment is restored from this file before any arguments are parsed.
+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/don't 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/don't use virtual circuit [novc] [no]defname (def) use/don't use default domain name [def] [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 trunc. 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 echo parsed arguments [cmd] [no]stats (st) print query statistics (RTT,etc) [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 # (# 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: dig always uses a value of 1 for num_servers.)
Pfset, pfand, and pfor 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 pkt 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 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 you are interested in.
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.