Dig

From LQWiki
Jump to navigation Jump to search

dig is a program used to manually send requests to DNS servers.

When using dig you can choose which server to ask (and override your settings from /etc/resolv.conf), so the program is often used to diagnose DNS-related problems.

It is distributed with BIND.

Dig answers look this way:

  $ dig linuxquestions.org

  ; <<>> DiG 9.2.3rc2 <<>> linuxquestions.org
  ;; global options:  printcmd
  ;; Got answer:
  ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45220
  ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 0

  ;; QUESTION SECTION:
  ;linuxquestions.org.            IN      A

  ;; ANSWER SECTION:
  linuxquestions.org.     3600    IN      A       64.179.4.149

  ;; AUTHORITY SECTION:
  linuxquestions.org.     3600    IN      NS      ns1.linuxquestions.org.
  linuxquestions.org.     3600    IN      NS      ns2.linuxquestions.org.
  linuxquestions.org.     3600    IN      NS      ns1.linuxquestions.net.

  ;; Query time: 211 msec
  ;; SERVER: 192.168.1.1#53(192.168.1.1)
  ;; WHEN: Thu Sep  9 22:57:54 2004
  ;; MSG SIZE  rcvd: 124

In the ANSWER SECTION there's IP address of the site (linuxquestions.org). AUTHORITY SECTION lists all DNS servers for the domain.

In the example above the default DNS server is used. To query a specific server use something like

  dig @192.168.1.1 linuxquestions.org

Dig is a replacement for nslookup.