Dig known as “Domain Information Groper” is a command that helps users with DNS-related tasks. It enables users to query DNS, check its configuration, collect information about it, troubleshoot network issues, and many more.
By default, the “dig” utility comes pre-installed in all modern Linux distributions including Debian 12. However, if you do not find it on your system, you can easily install it via your system’s package manager. It will allow you to display information about the domain names, and verify DNS settings by querying different types of DNS records, etc.
This post will illustrate the method to install and use “dig” on Debian 12.
Overview
- How to Install Dig on Debian 12
- How to Use Dig on Debian 12
- How to Uninstall/Remove Dig From Debian 12
- Bonus Tip: Alternatives of Dig Command in Debian 12
- Wrap Up
How to Install Dig on Debian 12
To install the “dig” command-line tool on Debian 12, you can install the “dnsutils” or “bind9-dnsutils” package from the default Debian repository. Both packages provide the necessary DNS tools for your system. Follow the given instructions to install “dig” on Debian 12:
Step 1: Update Debian System
First, update all the packages of your Debian system by utilizing the given command:
sudo apt upgrade
Step 2: Install “dig” on Debian 12
Next, install the “dnsutils” package on Debian system that provides DNS-related tools, such as dig, host, and nslookup:
Alternatively, you can also install the “bind9-dnsutils” package on your system. This package has the same tools as the “dnsutils” package but also includes the additional functions:
Step 3: Verify Installation
Finally, check the version of “dig” to ensure its installation on the Debian 12 system:
The output displays the installed version of “dig”:
How to Use Dig on Debian 12
The “dig” command is used to perform various tasks, such as checking DNS records, resolving DNS problems, verifying DNS configurations, getting information about the domain name, and many more. To use the “dig” command on Debian 12, follow the provided sections.
Basic Syntax of “dig” Command
The basic syntax of the “dig” command is provided below:
Here:
- “options” are the flags that are used to modify the “dig” command’s behavior.
- “name” is the domain name or IP address you want to query.
- “type” specifies the DNS record type that needs to be queried.
Common Options of “dig” Command
The “dig” command has a lot of options that can be used to change its behavior. The below table displays some of the frequently used “dig” options:
Option | Description |
---|---|
+noall | Clear all display flags |
+short | Displays only the answer section and excludes additional information |
+additional | Shows the additional section |
+authority | Displays only the authority section |
+stats | Prints the query statistics |
+answer | Shows the answer section only. |
+nocomments | Excludes the comments from the output |
+trace | Shows the fill DNS delegation path |
+recurse | Allow recursive querying |
-t | Specifies the record type for a query |
DNS Record Type for “dig” Command
In the “dig” command, you can also specify the DNS record type that defines the type of information associated with the domain name. The commonly used DNS record types are listed in the below table:
Record Type | Description |
---|---|
TXT (Text Record) | Displays the descriptive text-type records |
A (IPv4 IP address) | Translates the domain name to the IPv4 address |
MX (Mail Exchange) | Specifies mail host servers |
AAAA (IPv6 IP address) | Translates the domain name to the IPv6 address |
NS (Name Server) | Indicates authentic DNS servers for the domain |
SRV (Service) | Specifies the services’ location in the domain |
PTR (Pointer Record) | Define the domain name related to a particular IP address |
Using the “dig” Command in Debian 12
To use the “dig” command along with different options and DNS record types, check out the given use cases:
- Use Case 1: Perform a Basic DNS Query
- Use Case 2: Query For a Certain DNS Record Type
- Use Case 3: Query With a Particular DNS Server
- Use Case 4: Reverse DNS Lookup
- Use Case 5: Trace the DNS Path
- Use Case 6: Perform Multiple DNS Queries
Use Case 1: Perform a Basic DNS Query
To perform a basic query for a specific domain, use the “dig” command along with the desired domain name. For example, we are querying the “linuxways.net” domain as seen below:
In the below output:
- The first section displays the “dig” version installed on the system i.e. “9.18.24-1-Debian” and the “HEADER” section provides information about the query, such as its ID, opcode, status, etc.
- The second section provides information about the “EDNS” (Extended DNS) used in the query and the “QUESTION SECTION” indicates the domain being queried i.e. “linuxways.net”.
- The third section is the “ANSWER SECTION” which provides the actual response to the query. In our case, it indicates that “linuxways.net” has an “A” record of “172.67.140.252” and “104.21.70.243” IPv4 addresses.
- The fourth section displays the statistics information about the query including query time and server that provides the response, etc.
If you want to concise the output and display only the IP addresses associated with the specified domain, utilize the “+short” option in the “dig” command:
Moreover, you can also use the “+nocomments” option to display the output without including any comments:
Similarly, you can use various options to adjust the “dig” command’s behavior.
Use Case 2: Query for a Certain Record Type
If you want to query for a particular record type, specify your desired record type in the “dig” command. For instance, we are displaying the “TXT” DNS record for “linuxways.net”:
Similarly, to query for the “MX” record type of a domain, write out the following command:
Likewise, you can use the desired record type, such as AAAA, NS, or SRV to query the domain.
Use case 3: Query With a Particular DNS Server
You can also query a domain from a specific DNS server using the “@” symbol followed by the DNS server’s IP address. Here, we are querying for the “linuxways.net” domain with “8.8.8.8” (Google DNS server):
Use Case 4: Reverse DNS Lookup
To perform a reverse DNS lookup for finding the domain name associated with the specific IP address, type out the “dig -x” command followed by the particular IP address:
Use case 5: Trace the DNS Path
You can also trace the DNS lookup path by utilizing the “+trace” option in the “dig” command:
Use Case 6: Perform Multiple DNS Queries
If you want to perform multiple DNS lookups at once, you can do it by following the provided instructions.
First, create a text file using the “touch” command and specify the particular file name:
Then, open the created “.txt” file in the editor:
In the “DNS.txt” file, add the certain domain names that you want to query by writing in each line:
Now, perform the batch queries by using the “-f” option in the “dig” command along with the text file i.e. “DNS.txt” having a list of domain names:
Here, we used the “+short” option for the concise output:
How to Uninstall/Remove Dig From Debian 12
To uninstall or remove “dig” from Debian 12, just remove the related installed package from your system. If you have installed the “dnsutils” package, you can remove it through the below-listed command:
If you have the “bind9-dnsutils” package installed, remove it as:
To verify that “dig” has been successfully removed from the Debian 12 system, run any “dig” command as seen below:
Bonus Tip: Alternatives of Dig Command in Debian 12
In Debian 12, you can also use other alternative tools that perform similar functions as the “dig”. These tools include “nslookup”, “host”, “drill”, and “dog”.
Nslookup
The “nslookup” is a basic command-line utility for querying DNS servers and getting their information. You can use the “nslookup” command as:
Note: For additional information about “nslookup”, Check Out Our Dedicated Post About It.
Host
The “host” is another tool that is used for the quick DNS lookup. Here is how it works:
Drill
The “drill” is another best DNS lookup tool alternative to “dig” but it includes more advanced features. You can see its usage below:
Dog
The “dog” is also a popular command-line tool having the functionalities of “host” and “dig” for looking up DNS records. It provides the simple output as seen here:
That was all about installing, using, and removing “dig” and its alternatives in Debian 12.
Wrap Up
To install the “dig” utility on Debian 12, install the “dnsutils” or “bind9-dnsutils” package from the default Debian repository through the “sudo apt install <package-name>” command. These packages provide DNS-related tools, such as dig, host, and nslookup for the system. You can use “dig” to get detailed information about DNS records, testing, verifying, and troubleshooting DNS, and many more. This post has illustrated the method to install, use, and remove “dig” on the Debian 12 system.
I am a technical writer with a knack for learning and exploring new technologies. As a Computer Science Graduate, my expertise lies in the fundamentals of Programming languages and Linux OS. I strive to provide users with in-depth and informative articles that can help them understand the core concepts of modern technologies.