How to use the Dig command?

What does the Dig command mean?

Domain Information Groper is the abbreviation in the DIG command. It is a software that has the purpose of getting information about a domain. It can help you with detecting a problem with your domain. Simply by performing different DNS probing. You can see an individual DNS record or check a name server.

Dig command – 10 most popular examples

How to use it?

To begin, we have to open the Terminal on your Linux or macOS. To understand better how to use the Dig command, now we will examine a few examples.

Remark that we will use Page.com only for all our examples and a hypothetical IP address. The advice is to replace that part of the text. In the following commands, you just have to put the one that you need to check. Also, the same reference goes for the IP address. 

You will receive 3-part output. You will see the question you asked – your query, the result – answer, and the statistics for it. 

Dig an A record. Get the IP address of the target domain. With a direct dig command, it will show you extra information:

dig Page.com

The short version of the command will show you just the answer – the IP address.

dig Page.com +short

Dig an MX DNS record. See the mail servers for an exact domain’s incoming emails. You can check if they are well created. If they are not, you won’t be able to receive emails.

dig Page.com MX

Dig an SOA record. See which is the main server for the zone. 

dig Page.com SOA

Dig command to see all DNS records for this hostname. It is helpful for additional diagnostic of each of them. 

dig Page.com ANY

Dig an IP address and backtrack it to the domain. You can apply this command for reverse DNS check. See if you have set up your PTR records accurately. 

dig –x 123.123.123.123

Use a specific port for your dig request. Set up another port other than the default one – port 53.

dig –p 51 Page.com

Dig a TXT record. Find out if you have set up your SPF, DMARC, or another feature. 

dig Page.com TXT 

Dig command can be helpful with setting the DNS resolver you want. Also, to trace the route from there. In this case, we will use Google (8.8.8.8) and examine the hops of the query. 

dig @8.8.8.8 Page.com

If you want to trace the whole route of the DNS query (check the delegation path).

dig Page.com +trace

How to install the Dig command?

The Dig command is already installed by default in most of the Linux distros. If you are a Linux user and you want to check if you have it use this command:

dig -v

If it is installed, you will see the version of it. For example – DiG 9.11.3-1ubuntu1.7-Ubuntu. If you don’t have the Dig command, you will see – “dig command not found.”  

Don’t worry if you receive a negative message. You can install it quickly.

Ubuntu, Debian, Linux Mint, Kali Linux, and other Ubuntu-based and Debian-based.

sudo apt update && sudo apt install dnsutils

Arch Linux, Manjaro, and other Arch-based distros.

sudo pacman -S bind-tools

Red Hat, CentOS, or Fedora.

sudo yum install bind-utils

Recommended article: Host command explained