How to Install dig on Debian 12?
Dig (Domain Information Groper) is part of the BIND package, which is a popular DNS server software. If you are a web developer or a system administrator, you may need to use dig. It is a command-line tool that can query Domain Name System (DNS) servers and perform DNS lookups. It is useful for troubleshooting DNS issues, testing new configurations, and obtaining information about domain names and IP addresses.
This guide will learn how to install dig on Debian 12, and use some basic dig commands to troubleshoot DNS issues.
How to Install dig on Debian 12?
dig is a tool that allows users to query DNS servers and displays the output as a result. To install dig on Debian 12, install the “dnsutils” and “bind9-dnsutils” packages, which contain dig and other DNS-related utilities.
The supported methods to install dig on Debian 12 is given below:
Method 1: Install dig on Debian 12 Using dnsutils Package
dig is part of the dnsutils package, which also includes other DNS tools such as nslookup and host. To install dnsutils, follow these instructions:
Step 1: Update System Package
Before installing any package on Linux distribution, users need to update the system packages:
sudo apt update
Step 2: Install dnsutils Package (DNS Utility)
To install dig on Debian 12, install the “dnsutils” package name with the “apt” command. It installs dig and its dependencies on Debian 12:
sudo apt install dnsutils
Step 3: Verification
Users can verify the installation by running the “dig” command. It displays the version and DNS server query result:
dig
Optional: Check dig Version
To check the dig version on Debian 12, use the “v” or “version” utility as below. It confirms that version “9.18.19.1” is installed on Debian 12:
dig -v
This is all from the installation of dig using the “dnsutils” package on Debian 12.
Method 2: Install dig on Debian 12 Using bind9-dnsutils Package
dig is part of the “bind9-dnsutils” package, (also add other utilities e.g., “nslookup” and host). To install dig on Debian 12, users need to install the “bind9-dnsutils” package.
To install dig on Debian 12 using the “bind9-dnsutils” package, follow these steps:
Step 1 Update Package Lists
First, update the system packages list using the “update” command:
sudo apt update
Step 2: Install bind9-dnsutils Package
To install the “bind9-dnsutils” package on Debian 12, specify the package name with the “install” utility:
sudo apt install bind9-dnsutils
Step 3: Verification
To check the installation of dig on Debian 12, use the “dig” command on the terminal:
dig
This method has done the installation of dig with the latest “9.18.19-1” version on Debian 12.
How to Use Dig Commands on Debian 12?
dig permit users to query DNS servers and get data/information regarding domain names, IP addresses, and other records. To use dig commands on Debian 12 with various examples and explanations, users need to have the “dnsutils” package installed on Debian 12.
Basic Syntax
The basic syntax of dig command is given below:
dig [options] [name] [type]
In this syntax, “name” is the domain name or IP address that users want to query, and “type” is the record type to retrieve, such as A, MX, NS, TXT, etc. If users forget the record type, dig will default to “A” records, which are the most common ones.
Common Options of dig Command
Some of the common options that users can utilize with dig are:
| Options | Description |
| +short | Displays the answer section (only) of the dig output. |
| +noall | Suppresses all parts of the dig output except the ones that are specified with other options. |
| +answer | Displays the answer section of the dig output (only). |
| +authority | See only the authority section of the dig output. |
| +additional | Visualizes the additional section of the dig output (only), (info. about other records that are related to the query). |
| +trace | Traces the delegation path from the root name servers to the authoritative name servers for the queried domain. |
| +recurse | It enables recursive queries. |
| +norecurse | This option disables recursive queries. |
| +time=N | This option sets the timeout for each query to N seconds. |
| +tries=N | Sets the number of times to retry a query (for only no response). |
| +stats | Give statistics info about the query, |
One of the common uses of dig is to check the DNS propagation of a domain name after making some changes to its configuration.
Query the Domain Name (Google Server)
To use dig to query the domain name “google.com” on Debian 12, type the below command:
dig google.com
It sends a DNS query to the default nameserver and displays the output. It comprises various parts, each with several purposes.
Here is a brief explanation of each part:
- Information About the Query and the Answer
This section shows the basic information about the query as well as the answer. It includes the dig version, query parameters, status code, flags, and the number of records in each section:
- Extension Mechanisms for DNS
It shows the options for the Extension Mechanisms for DNS (EDNS), (protocol that allows DNS servers to exchange additional information). It includes the EDNS version, flags, UDP payload size, and cookie:
- Question Asked to Nameserver
It visualizes the question that was asked to the nameserver. It includes the domain name, the class (IN for Internet), and the type (A for IPv4 address):
- Answer Returned to Nameserver
It shows the answer that was returned by the nameserver. It includes the domain name, the time-to-live (TTL) in seconds, the class, the type, and the value of the record:
- Statistics About Query
It gives some statistics information about the query and the answer. It includes the query time in milliseconds, the IP address and port of the nameserver that answered the date and time of the query, and the size of the message in bytes:
Usage of dig Commands
To use dig commands on Debian 12, here are some examples of its use:
- Query for Specific Records
To query for MX records of “google.com”, use the “dig” command with the domain name and record type:
dig google.com MX
Users can also query for “TXT” records of “google.com” via the below command:
dig google.com TXT
- Using Specific Name Server
To query for A records of “google.com” using a specific name server (8.8.8.8):
dig @8.8.8.8 google.com
- Display Only Answer Section (Short Information)
To query for A records of “google.com” using a specific name server (8.8.8.8) and display only the answer section as below:
dig @8.8.8.8 google.com +short
- Display Answer and Authority Sections
To query for A records of “google.com” using a specific name server (8.8.8.8). It displays only the “answer” and “authority” sections (info about the authoritative name servers for the queried domain):
dig @8.8.8.8 google.com +noall +answer +authority
- Trace Delegation Path
To trace the delegation path between root name servers and authoritative (name servers) for “google.com”. It shows all the intermediate queries and responses:
dig google.com +trace
- Using Recursive Queries
To query for A records of “google.com” using recursive queries (dig will ask other name servers for the answer if the queried name server does not have it):
dig google.com +recurse
- Without Using Recursive Queries
To query for A records of “google.com” without using recursive queries (dig will only ask the queried name server for the answer and will not follow any referrals):
dig google.com +norecurse
- For Specific Time and Query
To query for A records of google.com with a timeout of 10 seconds and 5 retries. The timeout value is 5 seconds (default) and the retries value is 3 times:
dig google.com +time=10 +tries=5
- Display Statistics About Query
To query for A records of “google.com” and display statistics about the query (such as query time, message size, etc.):
dig google.com +stats
It is all about the installation and usage of dig utility/command on Debian 12.
Conclusion
dig is a valuable tool for troubleshooting DNS issues and performing domain name queries. To install dig on Debian 12, use the “dnsutils”, “bind9-dnsutils” packages and install them. It enables users to query any DNS server and get useful information about domain names. The best way to install dig on Debian 12 is to use the “dnsutils” package.
This blog has described all methods to install dig on Debian 12. Also seen how to use some of the most common dig options and flags to customize our queries and get valuable information.






















