Querying a DNS Server

 

Here are some methods of requesting information on a domain (e.g. NS records, MX records) from its authoritative DNS server:

  1. nslookup hostname
    • nslookup nyan.cat
      Server: 8.8.8.8
      Address: 8.8.8.8#53
      Non-authoritative answer:
      Name: nyan.cat
      Address: 208.97.169.68

        • You’ve asked the local DNS server at 8.8.8.8 to resolve the A record (i.e. Address) for nyan.cat, and the server responds with 208.97.169.68. By default, nslookup looks up the A record.
      • nslookup -querytype=mx google.com
        • You can also query for other record types. In the above case, mx denotes mail servers.
        • For the interactive mode:

          nslookup
          set type=mx
          google.com

  2. dig hostname
    • dig nyan.cat
      ; DiG 9.8.3-P1 nyan.cat
      ;; global options: +cmd
      ;; Got answer:
      ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29540
      ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
      ;; QUESTION SECTION:
      ;nyan.cat. IN A
      ;; ANSWER SECTION:
      nyan.cat. 14400 IN A 208.97.169.68
      ;; AUTHORITY SECTION:
      nyan.cat. 86313 IN NS ns2.dreamhost.com.
      nyan.cat. 86313 IN NS ns3.dreamhost.com.
      nyan.cat. 86313 IN NS ns1.dreamhost.com.
      ;; ADDITIONAL SECTION:
      ns1.dreamhost.com. 12742 IN A 64.90.62.230
      ns2.dreamhost.com. 102319 IN A 208.97.182.10
      ns3.dreamhost.com. 102319 IN A 66.33.205.230
      ;; Query time: 3621 msec
      ;; SERVER: 172.19.134.2#53(172.19.134.2)
      ;; WHEN: Thu Nov  9 20:05:47 2017
      ;; MSG SIZE  rcvd: 157

    • Above, nyan.cat points at 208.97.169.68 as shown in the ANSWER section. The A record is returned by default.
    • To query for any type of record:
      • dig nyan.cat any

  3.  host hostname
    • host nyan.cat
      nyan.cat has address 208.97.169.68

Advertisements