Dig command – What is it?
Domain information groper is the full name of the Dig command that is a simple built-in command used for various DNS probing. One of the main advantages it has it’s that you can use it on most Linux distros and any macOS computer. The Dig command allows you to perform quick checks of your DNS in a very simple way. For instance, you can view a specific DNS record or check a name server. You just have to open the Terminal app on your device. It has a command-line interface (CLI), which shows you all of the needed data in its output.
For what is it used?
Thanks to the Dig command, you are capable of viewing and checking a name server, different types of DNS records, completing a reverse DNS, and several other options. Let’s see what the Dig command is capable of:
- With it, you can check all name servers.
- It allows you to probe an individual name server once you view it from the earlier probe.
- You could search for all of the available DNS records for your domain.
- With it, you could check specifically for a particular type of DNS record, such as A, AAAA, MX, NS, SOA, TXT, CNAME, etc.
- You could perform Reverse DNS lookup by checking an IP address (IPv4 or IPv6) and seeing the hostname to which it corresponds.
- You can trace the entire route of a DNS query from a specific point, like your device or another resolver, to the hostname or IP address.
How to use the Dig command?
The first thing you should do is open the Terminal app on your Linux or macOS device. Then you could easily perform the following examples, but please make sure to use them with the domain and IP address you want to view.
Your result is going to be divided into three parts. You are going to notice the question you asked, meaning your query, the result, as an answer, and of course, the statistics.
All available DNS records for the host.
It could be beneficial for further diagnostic of each of them.
dig example.net ANY
When you want to see the IP (IPv4) address of a domain and use a direct dig command, it is going to give you additional data:
The short version of the command is going to give you only the IP address.
dig example.net +short
When you want to see which is the primary server for the DNS zone.
dig example.net SOA
When you want to see the mail servers for a precise domain and inspect if they are well made.
dig example.net MX
When you want to check if you have arranged your SPF record or TXT record.
dig example.net TXT
Reverse DNS lookup.
With the Dig command, you can see if you have accurately established your PTR records.
dig –x 184.108.40.206
Use a specific port.
You could set up a different port rather than the default one – port 53.
dig –p 51 example.net
Setting a DNS resolver.
It can be useful with selecting the DNS resolver you like. In addition, to trace the route from that point. In this example, we are going to utilize Google (220.127.116.11) and see if it can resolve the DNS zone successfully.
dig @18.104.22.168 example.net
Recommended article: How to check DNS propagation?