The Dig command is one of the most popular NSlookup alternatives for Linux and macOS. Here we will show you how to use it for checking your domain and all its DNS records.
What is the Dig command?
DIG is an abbreviation of Domain Information Groper, and it is a software with a command-line interface for domain probing. You can find the command on almost every Linux distro like CentOS, Ubuntu, Debian, Linux Mint, and more.
What is the Dig command used for?
The Dig command can perform various DNS queries and get information about different DNS records, including A DNS record, AAAA, MX, SOA, NS, PTR, and more.
Use the Dig command to check for problems with your domain or the functionality of your services like FTP or emails.
You can also regularly perform tests just to monitor your DNS performance.
How to use the Dig command?
Start the Terminal on your Linux or macOS. Now we will explore a few examples, so you get a general idea of how to use it.
Note that we will use ExamplePage.com as a target for all our examples and an imaginary IP address. You can change that part of the text in the following commands and put the one that you want to check. The same goes for the IP address.
You will have 3-part output. You will see what your query (the question you asked), the result (answer), and statistics for it was.
Dig an A record and get the IP address of the domain you are targeting. You can do it with a straightforward dig command that will show extra information:
dig ExamplePage.com
Or you can do it with the short version of the command that will show you just the answer (the IP address)
dig ExamplePage.com +short
Dig a MX DNS record and see the mail servers for a particular domain’s incoming emails. Check if they are well created because if they are not, you won’t be able to receive emails.
dig ExamplePage.com MX
Dig a SOA record and find out which is the main server for the zone.
dig ExamplePage.com SOA
Dig the TTL value and see for what amount of time does the recursive DNS servers keep the DNS records in their cache memory.
dig ExamplePage.com TTL
Dig command to see all DNS records that a domain has. It could be useful for further diagnostic of each of them.
dig ExamplePage.com ANY +noall +answer
Dig an IP address and backtrack it to the domain. You can use this command for reverse DNS check and see if you have set up your PTR records correctly.
dig –x 123.123.1.123
Use a specific port for your dig request. You can set up a different port than the default one, port 53.
dig –p 51 ExamplePage.com
Dig a TXT record and see if you have set up your SPF, DMARC, or another security feature.
dig ExamplePage.com TXT
When you are using the dig command, you can set the DNS resolver you want to use and trace the route from there. See, in this case, we will use google (8.8.8.8) and see the hops of the query.
dig @8.8.8.8 +trace ExampePage.com
Dig command options
If you want to master the Dig command, you can see the list of options that the dig command supports:
Option | Information |
-x dot-notation | Used for reverse DNS lookups (IPv4). |
-i | Used for reverse DNS lookups (IPv6). |
-f filename | Use a file for batch command. |
-b address [#port] | Bind to source address/port. |
-p port | Choose the port for the query. |
-q name | Query name. |
-t type | Type specification. |
-c class | Class specification. |
-k keyfile | Tsig key file specification. |
-y [hmac:]name:key | Name of a base64tsig key specification. |
-4 | IPv4 only. |
-6 | IPv6 only. |
-m | Memory usage debugging. |