IBM Support

Executing DIG Commands (Replacement for NSLOOKUP)

Troubleshooting


Problem

General DNS look ups and domain records can be queried by the use of the DIG command. This documentation describes the functionality of the DIG command and proper syntax, including options and explanations.

Resolving The Problem

General DNS look ups and domain records can be queried by the use of the DIG command. This documentation explains the functionality of the DIG command and proper syntax, including options and explanations.

Prerequisites

V6R1
SE35803 OSP-BIND 9.4.3b2 from 8.2.5

V7R1
Included with base operating system 5770SS1.
  • - Sample Query


    The following is a description of what is included on a generic DIG query. Explanation of DIG query options is explained at the conclusion of this document:

    $ dig IBM.com
                                                                                     
     ; <<>> DiG 9.4.3-P4.V6R1M0 <<>> IBM.com                                                    
     ;; global options:  printcmd                                                                
     ;; Got answer:                                                                              
     ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1077                                    
     ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 0                        
                                                                                                 
     ;; QUESTION SECTION:                                                                       
     ;IBM.com.                       IN      A                                                  
                                                                                                 
     ;; ANSWER SECTION:                                                                         
     IBM.com.                21600   IN      A       129.42.38.1                                
     ;; AUTHORITY SECTION:                                                         
     IBM.com.                172800  IN      NS      internet-server.zurich.IBM.com.
     IBM.com.                172800  IN      NS      ns.watson.IBM.com.            
     IBM.com.                172800  IN      NS      ns.almaden.IBM.com.            
     IBM.com.                172800  IN      NS      ns.austin.IBM.com.            
     
     ;; ADDITIONAL SECTION:                                                                               
     internet-s...           3600    IN      A       195.176.20.204      
     internet-s...           3599    IN      AAAA    ::::2005::1:1

     ;; Query time: 3463 msec                                                      
     ;; SERVER: 127.0.0.1#53(127.0.0.1)                                            
     ;; WHEN: Fri Apr 19 09:04:01 2013                                              
     ;; MSG SIZE  rcvd: 151                                                                                                                                                    


    The DIG command has variable sections that can be turned on or off during a query:

    HEADER: Displays DIG command version number and more global options. Notice before this section we can verify iOS version as well.
    QUESTION SECTION: Displays the query request sent to the target Domain's DNS server. Since a request was sent ‘DIG IBM.com’, the default type is an A record. We can request MX, PTR, and so on, record types.
    ANSWER SECTION: Displays the answer from our query sent to the Domain's DNS server. This output varies depending on what the records requested.
    AUTHORITY SECTION: Displays the DNS name server that has the authority to respond to this query. This section also displays available name servers of IBM.com.
    ADDITIONAL SECTION: Displays the IP address of the name servers listed in the AUTHORITY SECTION. This information is optional and might not be included depending on the security configuration of each DNS server.
    Stats can be displayed at the end of the query. This information is generic query timestamp.
    '

    - DIG Syntax

  • DIG query for A (alias) record type
    $ dig IBM.com A

    DIG query for MX (mail) record type
    $ dig IBM.com MX

    DIG query for NS (nameserver) record type
    $ dig IBM.com NS

    DIG query for SOA (start of authority) record type
    $ dig IBM.com SOA

    DIG query for IPv6 record types
    $ dig @9.10.244.100 IBM.com AAAA

    DIG query for ALL record types
    $ dig IBM.com ANY

    DIG query for reverse (PTR) lookup
    $ dig -x 209.132.183.81

    DIG query using a specific DNS Server
    $ dig @ns.watson.IBM.com IBM.com
    or
    $ dig @9.6.75.4 IBM.com

 
  • - Customize DIG Query



    You can customize your DIG commands so that your default requests will include DIG options of your choosing. Here is a generic view of ".digrc" located in your 'home/<Your User Home Folder>/.digrc' location:

    $ cat $HOME/.digrc
    +nostats +nocomments +nocmd +noquestion +recurse +answer

    Options Table

    • +short - Place this behind any request will display just the desired info. (Ex: DIG IBM.COM MX +short or DIG IBM.COM NS +short)
    •  +nocomments – Turn off the comment lines
    •  +noauthority – Turn off the authority section
    •  +noadditional – Turn off the additional section
    •  +noall - Turn off all sections
    •  +nostats – Turn off the stats section
    •  +noanswer – Turn off the answer section
    •  +trace - Trace the nameservers the queries are going to
    •  +answer - Turn on the answer section
    •  -x - perform a reverse lookup
    •  -axfr - perform a DNS zone transfer. Note this is commonly disables by nameservers due to security reasons


    Note: If this file does not exist you will receive an error message while trying to do the "CAT" command stating file is missing.

    The next time that you make a DIG query in QSH or command line, it will place the default options as long as you are logged in under the profile of the location of the .digrc file ('/home/yourhomefolder/').

  • Specifying DNS Servers and Options
The dig command does not use the DNS server information specified in the TCP/IP domain attributes.  Rather it uses the same resolv.conf file that would be used in a Unix-type environment.  The resolv.conf file is a text file located in the path /etc.  The /etc/resolv.conf file can contain entries to define dns servers and to provide default search domain suffixes.  For example, the following defines RCHLAND.IBM.COM as a default search suffix and defines two IP addresses for DNS servers.
search RCHLAND.IBM.COM IBM.COM 
nameserver 9.10.244.200        
nameserver 9.10.244.100        
       

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.1.0"}]

Historical Number

667772305

Document Information

Modified date:
24 June 2021

UID

nas8N1010417