dig (command)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

dig (domain information groper) is a Unix-like network administration command-line tool for querying Domain Name System (DNS) servers.

dig is useful for network troubleshooting and for educational purposes. dig can operate in interactive command line mode or in batch mode by reading requests from an operating system file. When a specific name server is not specified in the command invocation, it will use the operating system's default resolver, usually configured via the resolv.conf file. Without any arguments it queries the DNS root zone.

dig supports Internationalized Domain Name (IDN) queries.

dig is part of the BIND domain name server software suite. dig was initially planned to supersede older tools such as nslookup and the host program; however, it has instead become a complementary tool.

Example usage[edit]

In this example, dig is used to query for any type of record information in the domain example.com:

$ dig example.com any
; <<>> DiG 9.6.1 <<>> example.com any
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4016
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0

;example.com.                   IN      ANY

example.com.            172719  IN      NS      a.iana-servers.net.
example.com.            172719  IN      NS      b.iana-servers.net.
example.com.            172719  IN      A
example.com.            172719  IN      SOA     dns1.icann.org. hostmaster.icann.org. 2007051703 7200 3600 1209600 86400

;; Query time: 1 msec
;; SERVER: ::1#53(::1)
;; WHEN: Wed Aug 12 11:40:43 2009
;; MSG SIZE  rcvd: 154

The number 172719 in the above example represents the time to live value.

Queries may be directed to designated DNS servers for specific records; in this example, MX records:

$ dig wikimedia.org MX @ns0.wikimedia.org
; <<>> DiG 9.6.1 <<>> wikimedia.org MX @ns0.wikimedia.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61144
;; flags: qr aa rd; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 2
;; WARNING: recursion requested but not available

;wikimedia.org.                 IN      MX

wikimedia.org.          3600    IN      MX      10 mchenry.wikimedia.org.
wikimedia.org.          3600    IN      MX      50 lists.wikimedia.org.

mchenry.wikimedia.org.  3600    IN      A
lists.wikimedia.org.    3600    IN      A

;; Query time: 73 msec
;; WHEN: Wed Aug 12 11:51:03 2009
;; MSG SIZE  rcvd: 109

See also[edit]



  • Paul Albitz and Cricket Liu. DNS and BIND, 5th Edition. Nutshell Series. O'Reilly and Associates, Inc., 2006.

External links[edit]