List of content you will read in this article:
What is Dig Command
The full form of DIG is Domain Information Groper, which is a fantastic command-line tool. Dig is used for querying the DNS name server to display complete details on mail exchanges, host addresses, and other related information. You can use this tool on different operating systems such as Linux and macOS.
Many people use this tool to troubleshoot DNS-related issues due to its flexibility. This article will cover complete information on dig command with appropriate examples and every meticulous detail.
How to install DIG on your system?
First, install a dig in your system or your Linux VPS by using the specific commands in the Linux terminal.
If you want to install dig on Debian and Ubuntu, then use the below command:
sudo apt update && sudo apt install dnsutils
For installing dig on Fedora and CentOS, then use the below command:
sudo yum install bind-utils
For installing dig on Arch Linux, then use the below command:
sudo pacman -S bind-tools
How to check for the DIG command in Linux:
In case you want to check that the DNS dig command is available in your system, then use this command:
Once you execute the command, the system will show the output like this:
What is the Dig Syntax?
So here is the simplest form of dig syntax:
dig [server] [name] [type]
In this syntax, [server] shows the IP address of a name server for querying. In case the server argument is a hostname, then you can solve the hostname before processing by querying a name server. [name] consists of a name of a resource record that has to be looked up. [type] represents the type of query requested by the dig.
How to Use Dig Command
There are various ways to use the dg Linux command on any platform so we will cover all of the dig command's required details.
How to Perform Dig a Domain Name
If you want to use the DNS lookup for your domain name, use the following command:
Dig command will get displayed as a record when there are no other options available by default. The output of this command will also show other details such as the dig version, statistics of the query, technical information of answers, and the question with other ones.
This +short command will include some useful information about multiple sections but only use it when a result of a query is required.
dig 1gbits.com +short
You can use the command below in case you want to view a detailed answer section. This command line has +noall (stop displaying all of the sections) and +answer (used for querying answer sections).
dig 1gbits.com +noall +answer
How to Specify Nameservers
Dig commands can query all of the name servers by default, and these nameservers are listed in /etc/resolv.conf for performing a DNS lookup for the user. If you want to change it, use @ symbol with the name server's IP address or hostname.
dig @184.108.40.206 xyzdomaine.com
This command will send a DNS query to the name server of Google (220.127.116.11) through the @18.104.22.168 option.
How to Use Reverse DNS Lookup
Reverse DNS lookup is beneficial for looking up the domain as well as hostname related to the IP address. If you want to use the reverse DNS lookup, put the –x option with the selected IP address as a dig command. For example, we are using an IP address 123.453.232.66, so the command will look like this:
dig +answer -x 22.214.171.124
Note: If the IP address doesn't have a PTR record, you can't perform a DNS lookup.
How to use Batch Queries
You can perform the DNS lookup for the domain’s list instead of performing the same for every domain individually. You have to give the dig with the domain name’s list in the dig command like this:
dig -f domain_name.txt +short
This article has complete information on the dig command tool covering the installation process and different ways how to use it. So as we have explained previously, the word DIG stands for domain Information Groper, and it is a fantastic command-line tool.
To learn more about Linux commands, you can visit our previous blog. So we hope that our article will give you every single detail about dig commands for better understanding.
People are also reading: