DIG command: Query name servers

You can use DIG in command mode, where all options are specified on the invoking command line, or in batch mode, where a group of queries are placed in a data set and executed by a single invocation of DIG. DIG provides a large number of options for controlling queries and screen output, including most of the functions of NSLOOKUP.

You can create a data set for batch mode queries using the -f data_set option. The data set contains complete queries, one per line, that are executed in a single invocation of DIG. The keyword DIG is not used when specifying queries in a batch data set. Blank lines are ignored, and lines beginning with a # symbol or a semicolon (;) in the first column are comment lines.

Options specified on the initial command line are in effect for all queries in the batch data set unless explicitly overridden. Several options are provided exclusively for use within batch data sets, giving greater control over DIG operation.

Some internal state information is retrieved from the TCPIP.DATA data set. See the z/OS Communications Server: IP Configuration Guide for more information about the TCPIP.DATA data set.

Format

Read syntax diagramSkip visual syntax diagram
>>-DIG--+---------+--+-------------+--+-------+--+--------+----->
        '-@server-'  '-domain_name-'  '-qtype-'  '-qclass-'   

                   .-----------------------.   
                   V                       |   
>--+------------+----+-------------------+-+-------------------->
   '-%--comment-'    '-|  +queryoption |-'     

   .---------------------.   
   V                     |   
>----+-----------------+-+-------------------------------------><
     '-|  -digoption |-'     

 +queryoption

|--+----------------------------+-------------------------------|
   | .-noaaonly-.               |   
   +-+-aaonly---+---------------+   
   | .-addit---.                |   
   +-+-noaddit-+----------------+   
   | .-answer---.               |   
   +-+-noanswer-+---------------+   
   | .-author---.               |   
   +-+-noauthor-+---------------+   
   | .-nocl-.                   |   
   +-+-cl---+-------------------+   
   | .-cmd---.                  |   
   +-+-nocmd-+------------------+   
   | .-nod2-.                   |   
   +-+-d2---+-------------------+   
   | .-debug---.                |   
   +-+-nodebug-+----------------+   
   | .-defname---.              |   
   +-+-nodefname-+--------------+   
   +-domain--=--name------------+   
   | .-Header---.               |   
   +-+-noHeader-+---------------+   
   | .-header---.               |   
   +-+-noheader-+---------------+   
   | .-noignore-.               |   
   +-+-ignore---+---------------+   
   | .-noko-.                   |   
   +-+-ko---+-------------------+   
   +-pfand--=--number-----------+   
   +-pfdef----------------------+   
   +-pfmin----------------------+   
   +-pfor--=--number------------+   
   +-pfset--=--number-----------+   
   | .-noprimary-.              |   
   +-+-primary---+--------------+   
   | .-noqr-.                   |   
   +-+-qr---+-------------------+   
   | .-ques---.                 |   
   +-+-noques-+-----------------+   
   | .-recurse---.              |   
   +-+-norecurse-+--------------+   
   | .-reply---.                |   
   +-+-noreply-+----------------+   
   +-retry--=--limit------------+   
   | .-nosort-.                 |   
   +-+-sort---+-----------------+   
   | .-stats---.                |   
   +-+-nostats-+----------------+   
   +-timeout--=--time_out_value-+   
   | .-ttlid---.                |   
   +-+-nottlid-+----------------+   
   | .-novc-.                   |   
   '-+-vc---+-------------------'   

 -digoption

|--+---------------------------------------+--------------------|
   +-c-- --query_class---------------------+   
   +-envsav--------------------------------+   
   +-envset--------------------------------+   
   +-f-- --data_set------------------------+   
   +-P-------------------------------------+   
   | .-53---------.                        |   
   +-+-p-- --port-+------------------------+   
   | .-nostick-.                           |   
   +-+-stick---+---------------------------+   
   | .-0-------------.                     |   
   +-+-T-- --seconds-+---------------------+   
   +-t-- --query_type----------------------+   
   '-x-- --dotted_decimal_notation_address-'   

Parameters

@server
Specifies the domain name or IP address of the name server to contact for the query. The default is the name server specified in the TCPIP.DATA data set. TSO DIG can use only IPv4 addresses.

If a domain name is specified, DIG uses the resolver library routines provided in the TCP⁄IP for MVS™ programming interface to map the name to an IP address.

domain_name
Specifies the name of the domain for which information is requested. If the domain name does not exist in the default domain specified in the TCPIP.DATA data set, you must specify a fully qualified domain name.
qtype
Specifies the type of query to be performed. DIG does not support the MAILA, MD, MF, and NULL query types. The wildcard query types are ANY, MAILB, and AXFR. See the z/OS Communications Server: IP Configuration Reference for detailed information about valid query types.

If the qtype option is omitted, the default query type is A (an address query).

qclass
Specifies which network class to request in the query. DIG recognizes only the IN, CHAOS, HESIOD, and ANY network classes.
%comment
Provides a means of including comments in a DIG command. Any characters following the percent (%) character up to the next space character (space or end-of-record) are ignored by DIG. This option is useful in batch data sets for annotating a command.

For example, using a dotted decimal notation IP address rather than a domain name removes any overhead associated with address mapping; however, this makes the command less readable. Therefore, in a batch data set you can include the domain name as a comment for readability.

+queryoption
Interprets the string following the plus sign (+) character as a query option. Query options have the format:

parameter[=value]

and are a superset of the SET subcommand options for NSLOOKUP.
aaonly
Accepts only authoritative responses to queries.
noaaonly
Accepts all responses to queries. This option is the default.
addit
Prints the additional section of the response. The additional section contains resource records that have not been explicitly requested, but could be useful. See RFC 1035 for more information about this option. This option is the default.
noaddit
Does not print the additional section of the response.
answer
Prints the answer section of the response. The answer section contains the set of all resource records from the name server database that satisfy the query. This option is the default.
noanswer
Does not print the answer section of the response.
author
Prints the authoritative section of the response. The authoritative section contains resource records that specify the address of an authoritative name server for the query. This section is used when the name server queried cannot provide an authoritative answer. This option is the default.
noauthor
Does not print the authoritative section of the response.
cl
Prints network class information for each of the resource records returned.
nocl
Does not print network class information for each of the resource records returned. This option is the default.
cmd
Echos the parsed options. This option is the default.
nocmd
Does not echo the parsed options.
d2
Prints the details of each query sent out to the network, including send time stamp and the timeout time stamp. When a server does not respond within the timeout period, DIG either sends the query to another server, or resends the query to the original server. The details of the query are visible when d2 is set.
Note: You will not see any difference between debug, d2 and trace resolver. Resolver DNS responses and queries are traced for both options.
nod2
Does not print the details of each query sent out to the network. This option is the default.
debug
Directs DIG to print additional error messages. This option is the default.
nodebug
Directs DIG to not print additional error messages.
defname
Appends the default domain name to all unqualified domain names in a query. The default domain name is set by specifying the +domain=name option. This option is the default.
nodefname
Does not append the default domain name to all unqualified domain names in a query. This option causes the domain name specified to pass to the server without modification.
domain=name
Sets the default domain name to name. Initially the default domain name is obtained from the TCPIP.DATA data set. The validity of name is not verified. If the defname option is set, the domain name specified in name is appended to all unqualified domain names before the queries are sent to the name server.
Header
Prints the header line containing the operation code, returned status, and query identifier of each response. This option is distinct from the header option. This option is the default.
noHeader
Does not print the header line containing the operation code, returned status, and query identifier of each response.
header
Prints the query flags of each response. The query flags are defined in RFC 1035. This option is the default.
noheader
Does not print the query flags of each response.
ignore
Ignores truncation errors. Truncation errors occur when a response is too long for a single datagram.
noignore
Reports truncation errors. This option is the default.
ko
Keeps the virtual circuit open for queries in batch mode only. This option has no effect when used on the command line or when datagrams are used to transport queries (see the novc option later in this material).
noko
Does not keep the virtual circuit open for queries in batch mode only. This option is the default.
pfand=number
Performs a bitwise AND of the current print flags with the value specified in number. The number can be octal, decimal, or hexadecimal.
Note: To specify a number in octal, a 0 is required in front of the number. To specify a number in hexadecimal, 0X is required in front of the number.
pfdef
Sets the print flags to their default values. The default print flag values are 0x2FF9. For query type AXFR, the print flag values are 0x24F9.
Note: To specify a number in octal, a 0 is required in front of the number. To specify a number in hexadecimal, 0X is required in front of the number.
pfmin
Sets the print flags to the minimum default values. This option specifies that minimal information is printed for each response. The minimum print flag values are 0xA930.
Note: To specify a number in octal, a 0 is required in front of the number. To specify a number in hexadecimal, 0X is required in front of the number.
pfor=number
Performs a bitwise OR of the current print flags with the value specified in number. The number can be octal, decimal, or hexadecimal.
Note: To specify a number in octal, a 0 is required in front of the number. To specify a number in hexadecimal, 0X is required in front of the number.
pfset=number
Sets the print flags to the value specified in number. The number can be octal, decimal, or hexadecimal.
Note: To specify a number in octal, a 0 is required in front of the number. To specify a number in hexadecimal, 0X is required in front of the number.
The print flags are represented by a 16-bit value. The following list describes the individual bits of the print flags in order of most-significant bit to least-significant bit.
0
Sort reply records
1
Unused
2
Display reply section
3
Display query section
4
Show basic header
5
Display time to live (TTL) in reply records
6
Show flags for query and reply
7
Show section headers with reply record totals
8
Show additional subsections
9
Show authoritative subsection
10
Show answer subsections
11
Show question subsections
12
Echo DIG command line
13
Display query class info in reply records
14
Unused
15
Display statistics
primary
Includes only the primary name server for the zone, or includes the secondary name servers.
noprimary
Indicates that you should not use only the primary name server for the zone. This option is the default.
qr
Prints the outgoing query. The outgoing query consists of the header and the question, empty answer, additional, and authoritative sections. See RFC 1035 for more information about outgoing queries.
noqr
Does not print the outgoing query. This option is the default.
ques
Prints the question section of a response. The question section contains the original query. This option is the default.
noques
Does not print the question section of a response.
recurse
Requests a recursive query when querying a name server. This option is the default.
norecurse
Specifies that a recursive query is not requested.
reply
Prints the response from the name server. This option is the default.
noreply
Does not print the response from the name server. When this option is disabled, other print flags that affect printing of the name server response are ignored and no sections of the response are printed.
retry=limit
Specifies the number of times a request is resent. When a request is sent and the timeout period expires for a response, the request is resent until the value specified in limit has been exceeded. The value specified in limit determines the number of attempts made to contact the name server. The default value for limit is retrieved from the TCPIP.DATA data set.

Setting limit to 0 disables DIG from contacting the name server. The result is an error message no response from server.

The retry procedure for DIG uses both the limit value and the timeout period. Each time a request is resent, the timeout period for the request is twice the timeout period used for the last attempt.

sort
Sorts resource records before printing. Records are sorted alphabetically on record type names.
nosort
Does not sort resource records before printing. This option is the default.
stats
Prints the query statistics including time and date of query, size of query and response packets, and name of server used. This option is the default.
nostats
Does not print the query statistics.
timeout=time_out_value
Specifies the number of seconds to wait before timing out of a request. The default timeout value is retrieved from the data set.
ttlid
Prints the time to live (TTL) for each resource record in a response. This option is the default.
nottlid
Does not print the TTL for each resource record in a response.
vc
Uses a virtual circuit (TCP connection) to transport queries to the name server or datagrams. The default is retrieved from the TCPIP.DATA data set.
novc
Does not use a virtual circuit to transport queries to the name server or datagrams. This option is the default.
-digoption
Interprets the string following the hyphen (-) as a DIG option. The DIG options are either a parameter or a single character followed by a parameter.
c query_class
Specifies that the command-mode query or batch query retrieves resource records having the given network class. The qclass parameter, described in this topic, can also be used to specify the query class. In addition to the mnemonics, this option also accepts the equivalent numeric value that defines the class.
envsav
Directs DIG to save the environment specified on the current command line in the user_id.DIG.ENV data set. The DIG environment is described in DIG internal state information. This hlq.DIG.ENV data set initializes the default environment each time DIG is invoked.
envset
This option is valid for batch mode only. It directs DIG to set the default environment (see DIG internal state information) specified on the current line in the batch data set. This default environment remains in effect for all subsequent queries in the batch data set, or until the next line in the batch data set containing the -envset option is reached.
f data_set
Specifies a data set for DIG batch mode queries. The batch data set contains a list of queries that are to be executed in order. The keyword DIG is not used when specifying queries in a batch data set. Lines beginning with a number character (#) or semicolon (;) in the first column are comment lines, and blank lines are ignored. Options that are specified on the original command line are in effect for all queries in the batch data set unless explicitly overwritten. The following example shows a batch data set.
# A comment
; more comments
wurrup any in +noH =noqu -c IN
 
toolah +pfmin
Note: You must limit your query string to 99 characters to avoid error messages.
P
Directs DIG to execute a PING command for response time comparison after receiving a query response. The last three lines of output from the following command are printed after the query returns:
 PING server_name ( Length 56 Count 3
p port
Use the port number given when contacting the name server. The Domain Name System is a TCP⁄IP well-known service and has been allocated port 53. DIG uses port 53 by default, but this option enables you to override the port assignment.
stick
Restores the default environment (see DIG internal state information) before processing each line of a batch data set. This flag is valid for batch mode only. If you set the stick option, queries in the batch data set are not affected by the options specified for preceding queries in the data set.
nostick
Causes the query option specified on the current line in the batch data set to remain in effect until the option is overridden by a subsequent query. The result of each query in the batch data set depends on the preceding queries. This option is the default.
T seconds
Specifies the wait time between successive queries when operating in batch mode. The default wait time is 0 (do not wait).
t query_type
Specifies that the query retrieves resource records having the given resource record type. The qtype parameter, described in this topic, can also be used to specify the query type. In addition to the mnemonics, this parameter also accepts the equivalent numeric value that defines the type.
x dotted_decimal_notation_address
Simplifies the specification of a query for the in-addr.arpa domain. Normally these queries are made by specifying a query type of PTR for nn.nn.nn.nn.in-addr.arpa, where the four nn components are replaced by the dotted decimal notation IP address components in reverse order. This option enables you to make this query by simply specifying the dotted decimal notation IP address.

For example, the domain name corresponding to IP address 101.3.100.2 is found by a query for the domain name 2.100.3.101.in-addr.arpa. You can use DIG -x 101.3.100.2 rather than reversing the address and appending in-addr.arpa.

Examples

The following examples show how to use DIG to extract information from a name server. In Figure 1, the router wurrup has two IP addresses, and there are two name servers, wurrup being the primary name server. This network is described by a single zone in the domain naming hierarchy stored in the name servers.
Figure 1. A TCP⁄IP network
A TCP⁄IP network
In the examples, all queries are issued from the MVS uluru system.
Create a default environment (default options) that gives minimal output from subsequent DIG commands:
 System:
 Ready
 User:
 DIG wurrup +noqu +noH +nohe +nocmd +noad +noau +nost +nocl
 +nottl -envsav
 System:   ; Ques: 1, Ans: 2, Auth: 0, Addit: 0
           ;; ANSWERS:
           wurrup.FOUREX.OZ.  A       101.3.104.12
           wurrup.FOUREX.OZ.  A       101.3.100.12

The following queries show which part of the response output is controlled by each of the output control options. Each example enables or disables query options for tailoring output.

The following examples show how options control the use and value of the default domain.

The following lists the batch data set, test.digbat, used for this example. The default environment has been removed by discarding the user_id.DIG.ENV data set. The DIG command is omitted for all entries in the data set.

Note the effect of the -envset and -stick options on the output:

wurrup any in +noH +nohe +noqu +noad +noau -envset -stick
wurrup any in
toolah a in +d2
toolah a in
toolah a in +d2 -nostick
toolah a in
toolah a in +nod2
toolah a in
Specify the batch data set test.digbat:
 System:  Ready
 User:
 DIG -f test.digbat
 
 System:   ; <<>> DIG 2.0 <<>> DIG wurrup any in +noH +nohe +noqu +noad
           +noau -envset -stick
           ; Ques: 1, Ans: 3, Auth: 0, Addit: 0
 
           ;; ANSWERS:
           wurrup.FOUREX.OZ.  9999999 A       101.3.104.12
           wurrup.FOUREX.OZ.  9999999 A       101.3.100.12
           wurrup.FOUREX.OZ.  86400   HINFO   RS6000 AIX3.1
 
           ;; FROM: FOUREXVM1 to SERVER: default -- 101.3.104.40
           ;; WHEN: Tue Mar 16 11:15:57 1992
           ;; MSG SIZE  sent: 31  rcvd: 95
 System:   ; <<>> DIG 2.0 <<>> DIG wurrup any in
           ; Ques: 1, Ans: 3, Auth: 0, Addit: 0
           ;; ANSWERS:
           wurrup.FOUREX.OZ.  9999999 A       101.3.104.12
           wurrup.FOUREX.OZ.  9999999 A       101.3.100.12
           wurrup.FOUREX.OZ.  86400   HINFO   RS6000 AIX3.1
           ;; FROM: FOUREXVM1 to SERVER: default -- 101.3.104.40
           ;; WHEN: Tue Mar 16 11:15:57 1992
           ;; MSG SIZE  sent: 31  rcvd: 95
 System:   ; <<>> DIG 2.0 <<>> DIG toolah a in +d2
           ;; res_mkquery(0, toolah, 1, 1)
           ;; Querying server (# 1) address = 101.3.104.40
           ;; id = 3 - sending now: 4046124888 msec
           ; Ques: 1, Ans: 1, Auth: 0, Addit: 0
           ;; ANSWERS:
           toolah.FOUREX.OZ.  9999999 A       101.3.100.2
           ;; FROM: FOUREXVM1 to SERVER: default -- 101.3.104.40
           ;; WHEN: Tue Mar 16 11:15:57 1992
           ;; MSG SIZE  sent: 31  rcvd: 47
 System:   ; <<>> DIG 2.0 <<>> DIG toolah a in
           ; Ques: 1, Ans: 1, Auth: 0, Addit: 0
           ;; ANSWERS:
           toolah.FOUREX.OZ.  9999999 A       101.3.100.2
           ;; FROM: FOUREXVM1 to SERVER: default -- 101.3.104.40
           ;; WHEN: Tue Mar 16 11:15:57 1992
           ;; MSG SIZE  sent: 31  rcvd: 47
 System:   ; <<>> DIG 2.0 <<>> DIG toolah a in +d2 -nostick
           ;; res_mkquery(0, toolah, 1, 1)
           ;; Querying server (# 1) address = 101.3.104.40
           ;; id = 3 - sending now: 4046125037 msec
           ; Ques: 1, Ans: 1, Auth: 0, Addit: 0
           ;; ANSWERS:
           toolah.FOUREX.OZ.  9999999 A    101.3.100.2
           ;; FROM: FOUREXVM1 to SERVER: default -- 101.3.104.40
           ;; WHEN: Tue Mar 16 11:15:57 1992
           ;; MSG SIZE  sent: 31  rcvd: 47
 System:   ; <<>> DIG 2.0 <<>> DIG toolah a in
           ;; res_mkquery(0, toolah, 1, 1)
           ;; Querying server (# 1) address = 101.3.104.40
           ;; id = 5 - sending now: 4046125101 msec
           ; Ques: 1, Ans: 1, Auth: 0, Addit: 0
           ;; ANSWERS:
           toolah.FOUREX.OZ.  9999999 A       101.3.100.2
            ;; FROM: FOUREXVM1 to SERVER: default -- 101.3.104.40
           ;; WHEN: Tue Mar 16 11:15:57 1992
           ;; MSG SIZE  sent: 31  rcvd: 47
 System:   ; <<>> DIG 2.0 <<>> DIG toolah a in +nod2
           ; Ques: 1, Ans: 1, Auth: 0, Addit: 0
           ;; ANSWERS:
           toolah.FOUREX.OZ.  9999999 A       101.3.100.2
           ;; FROM: FOUREXVM1 to SERVER: default -- 101.3.104.40
           ;; WHEN: Tue Mar 16 11:15:57 1992
           ;; MSG SIZE  sent: 31  rcvd: 47
 System:   ; <<>> DIG 2.0 <<>> DIG toolah a in
           ; Ques: 1, Ans: 1, Auth: 0, Addit: 0
           ;; ANSWERS:
           toolah.FOUREX.OZ.  9999999 A       101.3.100.2
           ;; FROM: FOUREXVM1 to SERVER: default -- 101.3.104.40
           ;; WHEN: Tue Mar 16 11:15:58 1992
           ;; MSG SIZE  sent: 31  rcvd: 47

Usage

The queryoption and digoption parameters are case sensitive and must be entered in lowercase. Domain names, query types, query classes, and the values associated with queryoption and digoption parameters are not case sensitive.