From LQWiki
Jump to: navigation, 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

  ;linuxquestions.org.            IN      A

  linuxquestions.org.     3600    IN      A

  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:
  ;; 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 @ linuxquestions.org

Dig is a replacement for nslookup.