DIG is used to query information about various DNS records, including host addresses, mail exchganges, and name servers, eg. « dig maximef.com ».
Install dig on Linux (Optional)
Most modern Linux systems include the dig command.
Verify that it’s installed by checking the software version. To do so, open a command line and enter the following:
dig -v
The system should respond with a numeric code. If the system can’t find the command specified, install dig by entering the following:
Debian / Ubuntu:
sudo apt-get install dnsutils
CentOS / RedHat:
sudo yum install bind-utils
Once the installation finishes, verify the installation with the following command:
dig -v
How to Use the dig Command With Examples
Let’s look at the basic usage of the dig command.
Show canonical names (CNAMEs) or aliases that are associated with a domain name :
dig domain.tld cname
Show mail exchange records that are associated with a domaine name :
dig domain.tld mx
Show IPv6 addresses that are associated with a domain name :
dig domain.tld AAAA
Query a domain name associated with a specific IP address :
dig -x 1.1.1.1
Query for all records associated with a domaine name (A, AAAA, MX, NS, etc) :
host -v domain.tld host -a domain.tld
Configure system Domain Name System (DNS) resolver including local domain :
cat /etc/resolv.conf
Local listing of IP to hostnames. Takes precedence over DNS lookups :
cat /etc/hosts