UnixDroid

Network · Linux command

dig command in Linux

What does dig do?

dig asks DNS servers for records: A (IPv4), AAAA, MX (mail), TXT, NS and more.

dig [@server] name [type]

Most useful options

OptionWhat it does
A / MX / TXT / NSrecord type
+shortjust the answer
@8.8.8.8ask a specific server
-x IPreverse lookup

dig examples

$ dig example.com Try it ›

A record

$ dig example.com MX +short Try it ›

mail servers

$ dig -x 8.8.8.8 Try it ›

name of an IP

In security work

DNS records (TXT, MX, subdomains) are the first source in passive reconnaissance.

Questions about dig

What is the difference between dig and nslookup?

Both query DNS; dig shows more detail and is preferred for troubleshooting.