{{Short description|Network administration command-line tool}} {{refimprove|date=April 2011}} {{lowercase}} {{Infobox software | name = dig | logo = | screenshot = DiG 9.18.1 screenshot.png | screenshot size = | caption = | author = Steve Hotz, Michael Sawyer | developer = Internet Systems Consortium (originally Computer Systems Research Group) | repo = https://gitlab.isc.org/isc-projects/bind9/ | operating system = Linux, NetBSD, FreeBSD, OpenBSD, macOS, Windows, Solaris, illumos, OpenVMS | genre = DNS lookup tool | license = Mozilla Public License (ISC license before 9.11<ref>{{cite web|url=https://gitlab.isc.org/isc-projects/bind9/-/commit/0c27b3fe77ac1d5094ba3521e8142d9e7973133f|title=4401. [misc] Change LICENSE to MPL 2.0.|access-date=2026-02-22}}</ref>) | website = https://www.isc.org/bind/ }}

'''dig''' is a network administration command-line tool for querying the Domain Name System (DNS).

dig is useful for network troubleshooting and for educational purposes.<ref name="linuxize">{{Cite web |date=2020-02-26 |title=Dig Command in Linux (DNS Lookup) |url=https://linuxize.com/post/how-to-use-dig-command-to-query-dns-in-linux/ |access-date=2024-03-07 |website=linuxize.com}}</ref> It can operate based on command line option and flag arguments, 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 uses the operating system's default resolver, usually configured in the file resolv.conf. Without any arguments it queries the DNS root zone.

dig supports Internationalized domain name (IDN) queries.

dig is a component of the domain name server software suite BIND. dig supersedes in functionality older tools, such as nslookup and the program host; however, the older tools are still used in complementary fashion.

== Example usage ==

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

<syntaxhighlight lang="zone" highlight="1" style="font-size:8pt;"> $ 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

;; QUESTION SECTION: ;example.com. IN ANY

;; ANSWER SECTION: example.com. 172719 IN NS a.iana-servers.net. example.com. 172719 IN NS b.iana-servers.net. example.com. 172719 IN A 208.77.188.166 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 </syntaxhighlight>

The number '''''172719''''' in the above example is the time to live value, which indicates the time of validity of the data.

The '''''any''''' DNS query is a special meta query which is now deprecated. Since [https://datatracker.ietf.org/doc/html/rfc8482 around 2019], most public DNS servers have stopped answering most DNS '''''ANY''''' queries usefully [https://blog.cloudflare.com/rfc8482-saying-goodbye-to-any/ RFC8482 - Saying goodbye to ANY].

If '''''ANY''''' queries do not enumerate multiple records, the only option is to request each record type (e.g. A, CNAME, or MX) individually.

=== Specific DNS server === Queries may be directed to designated DNS servers for specific records; in this example, MX records: <syntaxhighlight lang="zone" highlight="1" style="font-size:8pt;"> $ dig wikimedia.org MX @ns0.wikimedia.org ; <<>> DiG 9.11.3 <<>> wikimedia.org MX @ns0.wikimedia.org ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39041 ;; flags: qr aa rd; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1024 ; COOKIE: c9735311d2d2fa6e3b334ab01b67960d (good) ;; QUESTION SECTION: ;wikimedia.org. IN MX

;; ANSWER SECTION: wikimedia.org. 3600 IN MX 10 mx1001.wikimedia.org. wikimedia.org. 3600 IN MX 50 mx2001.wikimedia.org.

;; Query time: 1 msec ;; SERVER: 208.80.154.238#53(208.80.154.238) ;; WHEN: Sat Sep 18 21:33:24 PDT 2021 ;; MSG SIZE rcvd: 108 </syntaxhighlight>

=== With output formatting === There are many [https://downloads.isc.org/isc/bind9/9.20.11/doc/arm/html/manpages.html#dig-dns-lookup-utility output formatting options] available. A common selection to make the output more terse is:

<syntaxhighlight lang="zone" highlight="1" style="font-size:8pt;"> $ dig +noall +answer +multiline wikimedia.org MX wikimedia.org. 3600 IN MX 10 mx1001.wikimedia.org. wikimedia.org. 3600 IN MX 50 mx2001.wikimedia.org. </syntaxhighlight>

Where '''''+noall +answer +multiline''''' are simply output formatting flags.

==History==

dig was originally written by Steve Hotz and incorporated into BIND 4 since at least 1990;<ref name=hotz>{{cite web |title=dig (4.4BSD of 1990) |url=https://man.freebsd.org/cgi/man.cgi?query=dig&apropos=0&sektion=0&manpath=4.4BSD+Lite2&arch=default&format=html |website=man.freebsd.org |access-date=2024-05-17}}</ref> later it was rewritten by Michael Sawyer, and is maintained by the Internet Systems Consortium as part of BIND 9.

When originally written, the manual page for dig indicated that its name was an acronym for "Domain Information Groper".{{r|hotz}} This expansion was removed in 2017; the tool's name is now simply "dig".<ref>{{cite web |title=remove unnecessary acronym expansions |url=https://gitlab.isc.org/isc-projects/bind9/-/commit/cee0d603a3b142df744d94b18cf42f086cdb0ff7 |website=gitlab.isc.org | date=2017-07-28|access-date=2025-11-23}}</ref>

==See also== * BIND name server * Root name server – top-level name servers providing top level domain name resolution * List of DNS record types – possible types of records stored and queried within DNS * whois * host is a simple utility for performing Domain Name System lookups * nslookup, another utility that can be used to obtain similar information

==References== {{Reflist}}

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

==External links== * [https://downloads.isc.org/isc/bind9/9.20.11/doc/arm/html/manpages.html#dig-dns-lookup-utility Official BIND 9 man page for dig] * [https://www.madboa.com/geek/dig/ How to use dig to query DNS name servers] * [https://gitlab.isc.org/isc-projects/bind9/-/tree/main/bin/dig Dig source code in ISC Gitlab repository]

{{Unix commands}}

Category:DNS software Category:Domain Name System Category:Free network-related software