LinuxCommandLibrary

dig

DNS lookup and troubleshooting utility

TLDR

Query DNS

$ dig [example.com]
copy
Specific record type
$ dig [example.com] [A]
copy
Short answer
$ dig [example.com] +short
copy
Reverse lookup
$ dig -x [8.8.8.8]
copy
Query specific nameserver
$ dig [@8.8.8.8] [example.com]
copy

SYNOPSIS

dig [@server] [name] [type]

DESCRIPTION

dig (Domain Information Groper) is a DNS lookup utility. It queries DNS servers for various record types, provides detailed responses, and is the preferred tool for DNS troubleshooting and analysis.
The command has largely replaced older tools like nslookup.

PARAMETERS

@server

Query specific DNS server
+short
Brief output (just answer)
+noall +answer
Show only answer section
-x ip
Reverse lookup
-t type
Record type (A, AAAA, MX, NS, etc.)
+trace
Trace DNS delegation path
+dnssec
Request DNSSEC records
-4 / -6
Use IPv4 / IPv6 only

RECORD TYPES

A

IPv4 address
AAAA
IPv6 address
MX
Mail exchange
NS
Name servers
TXT
Text records
CNAME
Canonical name (alias)
SOA
Start of authority
PTR
Reverse lookup pointer
SRV
Service locator
ANY
All available records

WORKFLOW

$ # Basic lookup (A record)
dig example.com

# Specific record type
dig example.com MX
dig example.com AAAA

# Short answer only
dig example.com +short

# Multiple queries
dig example.com A AAAA MX

# Query specific DNS server
dig @8.8.8.8 example.com
dig @1.1.1.1 example.com

# Reverse lookup
dig -x 8.8.8.8

# Trace delegation
dig example.com +trace

# Show only answer
dig example.com +noall +answer

# Query all records
dig example.com ANY
copy

DNS SERVERS

Common public DNS:
- 8.8.8.8 - Google DNS
- 1.1.1.1 - Cloudflare DNS
- 9.9.9.9 - Quad9

ADVANCED QUERIES

$ # Check DNSSEC
dig example.com +dnssec

# Query specific port
dig -p 5353 example.com

# Batch file queries
dig -f domains.txt

# TCP instead of UDP
dig +tcp example.com

# Show query time
dig example.com +stats
copy

OUTPUT SECTIONS

QUESTION - Query sent
ANSWER - Response records
AUTHORITY - Authoritative nameservers
ADDITIONAL - Additional information

CAVEATS

Requires network connectivity. Default uses system DNS. Complex output for beginners. Some ISPs intercept DNS. DNSSEC validation requires proper setup. Large queries may timeout.

HISTORY

dig was developed by Steve Hotz at USC's Information Sciences Institute in 1989, becoming part of BIND and the standard DNS debugging tool.

SEE ALSO

host(1), nslookup(1), drill(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community