There's a fine tool for checking the operation of your name server setup. It is called nslookup, and may be used both interactively and from the command line. In the latter case, you simply invoke it as
and it will query the name server specified in resolv.conf for hostname. (If this file names more than one server, nslookup will choose one at random).
The interactive mode, however, is much more exciting. Besides looking up individual hosts, you may query for any type of DNS record, and transfer the entire zone information for a domain.
When invoked without argument, nslookup will display the name server it uses, and enter interactive mode. At the `>' prompt, you may type any domain name it should query for. By default, it asks for class A records, those containing the IP address relating to the domain name.
You may change this type by issuing ``set type=type'', where type is one of the resource record names described above in section , or ANY.
For example, you might have the following dialogue with it:
$ nslookup Default Name Server: rs10.hrz.th-darmstadt.de Address: 22.214.171.124 > sunsite.unc.edu Name Server: rs10.hrz.th-darmstadt.de Address: 126.96.36.199 Non-authoritative answer: Name: sunsite.unc.edu Address: 188.8.131.52
If you try to query for a name that has no IP address associated, but other records were found in the DNS database, nslookup will come back with an error message saying ``No type A records found''. However, you can make it query for records other than type A by issuing the ``set type'' command. For example, to get the SOA record of unc.edu, you would issue:
> unc.edu *** No address (A) records available for unc.edu Name Server: rs10.hrz.th-darmstadt.de Address: 184.108.40.206 > set type=SOA > unc.edu Name Server: rs10.hrz.th-darmstadt.de Address: 220.127.116.11 Non-authoritative answer: unc.edu origin = ns.unc.edu mail addr = shava.ns.unc.edu serial = 930408 refresh = 28800 (8 hours) retry = 3600 (1 hour) expire = 1209600 (14 days) minimum ttl = 86400 (1 day) Authoritative answers can be found from: UNC.EDU nameserver = SAMBA.ACS.UNC.EDU SAMBA.ACS.UNC.EDU internet address = 18.104.22.168
In a similar fashion you can query for MX records, etc. Using a type of ANY returns all resource records associated with a given name.
> set type=MX > unc.edu Non-authoritative answer: unc.edu preference = 10, mail exchanger = lambada.oit.unc.edu lambada.oit.unc.edu internet address = 22.214.171.124 Authoritative answers can be found from: UNC.EDU nameserver = SAMBA.ACS.UNC.EDU SAMBA.ACS.UNC.EDU internet address = 126.96.36.199
A practical application of nslookup beside debugging is to obtain the current list of root name servers for the named.ca file. You can do this by querying for all type NS records associated with the root domain:
> set typ=NS > . Name Server: fb0430.mathematik.th-darmstadt.de Address: 188.8.131.52 Non-authoritative answer: (root) nameserver = NS.INTERNIC.NET (root) nameserver = AOS.ARL.ARMY.MIL (root) nameserver = C.NYSER.NET (root) nameserver = TERP.UMD.EDU (root) nameserver = NS.NASA.GOV (root) nameserver = NIC.NORDU.NET (root) nameserver = NS.NIC.DDN.MIL Authoritative answers can be found from: (root) nameserver = NS.INTERNIC.NET (root) nameserver = AOS.ARL.ARMY.MIL (root) nameserver = C.NYSER.NET (root) nameserver = TERP.UMD.EDU (root) nameserver = NS.NASA.GOV (root) nameserver = NIC.NORDU.NET (root) nameserver = NS.NIC.DDN.MIL NS.INTERNIC.NET internet address = 184.108.40.206 AOS.ARL.ARMY.MIL internet address = 220.127.116.11 AOS.ARL.ARMY.MIL internet address = 18.104.22.168 AOS.ARL.ARMY.MIL internet address = 22.214.171.124 C.NYSER.NET internet address = 126.96.36.199 TERP.UMD.EDU internet address = 188.8.131.52 NS.NASA.GOV internet address = 184.108.40.206 NS.NASA.GOV internet address = 220.127.116.11 NS.NASA.GOV internet address = 18.104.22.168 NIC.NORDU.NET internet address = 22.214.171.124 NS.NIC.DDN.MIL internet address = 126.96.36.199
The complete set of commands available with nslookup may be obtained by the help command from within nslookup.