All query options are accessible from the command line.
The typical use of dig is:
dig @server domain query-type query-class
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.
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.
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.)
in | C_IN | Internet class domain |
any | C_ANY | all/any class information |
you can use:
dig -x 128.9.0.32
A different version of the ping command may be specified in ping_string.
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.
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 |
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 (2i)) / num_servers) end end
See also the explanation of the -envsav and -envset and -[no]stick options, above.
RFC 1035
dig does not consistently exit nicely (with appropriate status) when a problem occurs somewhere in the resolver.
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.