NSLOOKUP examples

This material contains examples of NSLOOKUP command-mode queries, and interactive-mode queries using the various options available for NSLOOKUP commands.

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. Hierarchical naming tree—A TCP⁄IP network
Hierarchical naming tree—A TCP⁄IP network

The following examples show how to use NSLOOKUP to extract information from a name server. The queries are executed from the z/OS® host uluru on the network described in Figure 1.

The following examples are command-mode queries.
  • To make a simple address query:
      User:    nslookup toolah.fourex.oz wurrup.fourex.oz
    System:  Server:  wurrup
             Address:   101.3.104.12
     
             Name:   toolah.fourex.oz
             Address:   101.3.100.2
  • To specify a name server (NS) type record lookup:
      User:    nslookup -querytype=ns fourex.oz
    System:  Server:  canetoad
             Address:   101.3.104.40
     
             fourex.oz  nameserver = wurrup.fourex.oz
             fourex.oz  nameserver = canetoad.fourex.oz
             wurrup.fourex.oz   internet address = 101.3.100.12
             wurrup.fourex.oz   internet address = 101.3.104.12
             canetoad.fourex.oz internet address = 101.3.104.40
  • To specify a different default domain name to be appended to an unqualified domain name given as input:
      User:    nslookup -do=fourex.oz uluru
    System:  Server:  canetoad.fourex.oz
             Address:  101.3.104.40
     
             Name:    uluru.fourex.oz
             Address:  101.3.104.38
     
  • To specify a list of domain names to be appended in turn to the unqualified host name when attempting to resolve it:
      User:    nslookup -srchlist=nowhere.oz/fourex.oz uluru
    System:  Server:  canetoad.fourex.oz
             Address:  101.3.104.40
     
             Name:    uluru.fourex.oz
             Address:  101.3.104.38
     
The following command places NSLOOKUP in interactive mode with wurrup as the default server.
 User:
 nslookup - wurrup
 System:   Default Server:  wurrup
 Address:   101.3.104.12
All following examples are in the interactive mode initiated in the preceding example.
  • Show the default flag settings:
     User:
     set all
     Default Server:  wurrup.fourex.oz
     Address:  101.3.104.12
     
      Set options:
        nodebug             defname         nosearch        recurse
        nod2                novc            noignoretc      port=53
        querytype=A         class=IN        timeout=60      retry=1
        root=ns.nic.ddn.mil.
        domain=FOUREX.OZ    
        srchlist=FOUREX.OZ
  • Perform a simple address query:
     User:
     toolah
     System:    Server:  wurrup
     Address:   101.3.104.12
     
     Name:    toolah.FOUREX.OZ
     Address:  101.3.100.2
  • Set the query record type to HINFO, and perform another query:
     User:
     set q=HINFO
     toolah
     System:     Server:  wurrup
     Address:   101.3.104.12
     
     toolah.FOUREX.OZ   CPU = RS6000     OS = AIX3.1
  • Find out the name servers available for a domain:
     User:
     set q=NS
     fourex.oz
     System:   Server:  wurrup
     Address:   101.3.104.12
     
     fourex.oz  nameserver = wurrup.fourex.oz
     fourex.oz  nameserver = canetoad.fourex.oz
     wurrup.fourex.oz   internet address = 101.3.100.12
     wurrup.fourex.oz   internet address = 101.3.104.12
     canetoad.fourex.oz internet address = 101.3.104.40
  • Change the current server from wurrup to canetoad and make more queries:
     User:   server canetoad
     System:   Default Server:  canetoad.FOUREX.OZ
     Address:   101.3.104.40
     
     User:
     set q=A
     gecko
     System:   Server:  canetoad.FOUREX.OZ
     Address:   101.3.104.40
     
     Name:    gecko.FOUREX.OZ
     Address:  101.3.100.90
  • Enable debugging and execute a simple query to see the result, and then disable debugging:
     User:
     set deb
     wurrup
     System:   Server:  canetoad.FOUREX.OZ
     Address:   101.3.104.40
     
               res_mkquery(0, wurrup.FOUREX.OZ, 1, 1)
               ------------
               Got answer:
                  HEADER:
                     opcode = QUERY, id = 7, rcode = NOERROR
                     header flags:  response, auth. answer, want recursion,
                     recursion avail
                     questions = 1, answers = 2, authority records = 0,
                     additional = 0
     
                  QUESTIONS:
                     wurrup.FOUREX.OZ, type = A, class = IN
                  ANSWERS:
                  -> wurrup.FOUREX.OZ
                     internet address = 101.3.104.12
                     ttl = 9999999 (115 days 17 hours 46 mins 39 secs)
                  -> wurrup.FOUREX.OZ
                     internet address = 101.3.100.12
                     ttl = 9999999 (115 days 17 hours 46 mins 39 secs)
     
               ------------
     Name:    wurrup.FOUREX.OZ
              Addresses:  101.3.104.12, 101.3.100.12
     User:
     set nodeb
  • Find all addresses in the fourex.oz domain using the ls option:
     User:
     ls fourex.oz
     System:   [canetoad.FOUREX.OZ]
               fourex.oz                     server = wurrup.fourex.oz
               wurrup                         101.3.100.12
               wurrup                         101.3.104.12
               fourex.oz                     server = canetoad.fourex.oz
               canetoad                       101.3.104.40
               gecko                          101.3.100.90
               wurrup                         101.3.100.12
               wurrup                         101.3.104.12
               galah                          101.3.100.20
               bandicoot                      101.3.104.52
               toolah                         101.3.100.2
               canetoad                       101.3.104.40
               loopback                       127.0.0.1
               uluru                          101.3.104.38
  • Find all aliases in the fourex.oz domain, then exit from NSLOOKUP interactive mode:
     User:
     ls -a fourex.oz
     System:  [canetoad.FOUREX.OZ]
               localhost                      loopback.fourex.oz
               infoserver                     wurrup.fourex.oz
               pabxserver                     wurrup.fourex.oz
     User:
     exit
  • To display a summary of available commands:
     User:
     help
     System:
     Commands:       (identifiers are shown in uppercase, <> means optional)
     NAME            - print info about the host/domain NAME using default server
     NAME1 NAME2     - as above, but use NAME2 as server
     help or ?     - print info on common commands; see nslookup man for details
     set OPTION      - set an option
         all         - print options, current server and host
         <no>debug   - print debugging information
         <no>d2      - print exhaustive debugging information
         <no>defname - append domain name to each query
         <no>recurse - ask for recursive answer to query
         <no>vc      - always use a virtual circuit
         domain=NAME - set default domain name to NAME
         srchlist=N1</N2/.../N6> - set domain to N1 and search list to N1,N2, etc.
         root=NAME   - set root server to NAME
         retry=X     - set number of retries to X
         timeout=X   - set initial time-out interval to X seconds
         querytype=X - set query type, e.g., A,ANY,CNAME,HINFO,MX,NS,PTR,SOA,WKS
         type=X      - synonym for querytype
         class=X     - set query class to one of IN (Internet), CHAOS, HESIOD or ANY
     server NAME     - set default server to NAME, using current default server
     lserver NAME    - set default server to NAME, using initial server
     finger <USER>   - finger the optional NAME at the current default host
     root            - set current default server to the root
     ls <opt> DOMAIN ^> DATASET| - list addresses in DOMAIN
                       (optional: output to DATASET)
         -a          -  list canonical names and aliases
         -h          -  list HINFO (CPU type and operating system)
         -s          -  list well-known services
         -d          -  list all records
         -t TYPE     -  list records of the given type (e.g., A,CNAME,MX, etc.)
     view DATASET  - sort an 'ls' output file and view it with more
     exit          - exit the program
  • To find information for all the users currently logged in on the node specified in the last address query:
     User:
     finger
     System:
     [canetoad.FOUREX.OZ]
     Further output to be generated ....
  • To set the default domain name to fourex.oz, use the command
    set domain=fourex.oz

    This command overrides the DOMAINORIGIN statement in the tcpip.TCPIP.DATA data set.

  • To specify that the default domain name is to be appended to an unqualified domain name given in a query, use the SET defname command.
  • To request that the query be resent three times if the timeout period expires for a response, use the SET retry=3 command. A value of 3 is the maximum valid value.