dig: command not found

A powerful tool for gathering information and testing name resolution. It is installed on most Linux distributions. Output is displayed in an answer section. The output will include the IP address mapped to the domain name, the DNS server that answered the query, and how long it took to receive that answer.

Syntax

The basic syntax is:

# dig {domain name}

The command dig @{IP address} {domain name} will resolve the domain name against the DNS server specified by the IP address.

If you encounter the below error while running the dig command:

dig: command not found

you may try installing the below package as per your choice of distribution:

OS Distribution Command
Debian apt-get install knot-dnsutils
Ubuntu apt-get install knot-dnsutils
Alpine apk add bind-tools
Arch Linux pacman -S bind-tools
Kali Linux apt-get install dnsutils
Fedora dnf install bind-utils
Raspbian apt-get install knot-dnsutils

dig Command Examples

1. To dig into any domain name server:

# dig centos.com

2. To hide any particular section from the output:

# dig centos.com +noanswer
# dig centos.com +noadditional 
# dig centos.com +nostats
# dig centos.com +noauthority
# dig centos.com +nocomments

3. To query all types of records:

# dig centos.com -t ANY

4. To query MX records (Mail Exchanger records):

# dig centos.com MX
# dig centos.com -t MX

5. To query SIG records (Signature Records):

# dig centos.com -t SIG

6. To query NS records (Name server records):

# dig centos.com -t NS

7. To query TXT records (Text records):

# dig centos.com -t TXT

8. To see the summarized output:

# dig centos.com +short

9. To do the reverse DNS lookup of the server:

# dig -x centos.com

10. Perform iterative queries and display the entire trace path to resolve a domain name:

# dig +trace example.com

11. Find authoritative name servers for the zone and display SOA records:

# dig +nssearch example.com

12. Query a specific DNS record type associated with a given domain name:

# dig +short example.com A|MX|TXT|CNAME|NS

13. Lookup the IP(s) associated with a hostname (A records):

# dig +short example.com

14. Get a detailed answer for a given domain (A records):

# dig +noall +answer example.com
Related Post