
Domain Information Groper (dig) is a Linux utility tool that queries Domain Name System (DNS) information for a particular hostname or IP Address. By usage, the dig utility allows you to:
By functionality, dig checks IP addresses mapped to domain names and any additional records associated with the domain. This guide explains how to look up DNS records using the dig CLI Tool on a Linux server.
Before you start:
Switch to the sudo user account
dig CLI ToolThe dig utility works on all Linux distributions, but the installation process differs per system. It's part of a larger dnsutils package that additionally enables several DNS client utilities like nsupdate and nslookup. Install the dig CLI tool as described in the following steps
Install the dnsutils package on your server
On Ubuntu/Debian:
CentOS 7:
Fedora/Rocky Linux:
Arch Linux:
When installed, verify the available dig version
Output:
dig Usage SyntaxThe dig utility uses the following command syntax to fetch DNS records
Below are the available command options:
@DNS_SERVER: Defines the name or IP address of the server that performs the query. In short, it sets the DNS database that responds when you submit a query. For example, a hostname, IPv4, or IPv6 addressNAME: Defines the resource you want to know more about. For instance, to perform a DNS lookup for the example.com domain, define the domain name when running the dig utilityTYPE: The type of query to perform. For example, ANY, A, MX, or NS records. When the TYPE option is not used, the dig command performs a lookup for the A record. Below are the most common DNS record query types you can perform using the dig command:A: Links a domain name to an IP address. This is the main query performed by the dig commandNS: Returns the domain name's authoritative nameserver. This record displays the nameserver hosting the domain's DNS recordsMX: Returns a domain's mail server recordsCNAME: Also known as Canonical Name, it maps one domain name to another and it's often used to resolve domain variations. By usage, it shows that one domain name is an alias for another domain. For example www.example.com is a CNAME to example.comTXT: Returns the email server verification recordsANY: Returns all records of a queryQUERY_OPTIONS: Affects how dig performs and displays the DNS lookup results. Options are relevant when you want to limit the query answers, timeout, and retry strategies. Below are the sample query options:+short: Displays short query outputs+noall: Clears all default output flags+trace: Traces the path a query takes in a hierarchical manner+cmd: Removes comments from the outputdig CommandTo test and verify how the dig utility tool works, perform sample DNS look-up operations as described below.
Query the example.com domain A record
Output:
Repeat the above query, but use the +short option to return only the most relevant information
Output:
Query the domain nameserver (NS) records. Clear the default outputs using +noall, and display a short response
Output:
As displayed in the output, the query returns two nameserver records. This is because a domain name hosts at least two NS records for high availability and load balancing. The nameserver's redundancy setting ensures that DNS queries are successful even when some servers are offline.
Query the domain's MX records
Output:
As displayed in the above output, the domain example.com does not have any MX records. When you query a domain with MX entries, the records display in your output
Using the +trace option, find the example.com DNS path
Output:
To redirect a dig query to a specific DNS server and display a short answer with no comments, use the +nocmd, +noall, +answer options as below
Output:
In this guide, you installed and used the dig utility tool to look up domain DNS records. The dig utility offers multiple options you can use to enhance your DNS lookup operations. run the dig -h command to view all available options depending on your query needs. When used effectively, the dig command allows you to quickly detect and resolve major DNS issues when working with production cloud servers.
To use other utility tools on your Vultr Cloud Server. Visit the following resources:
0 Comments
Be the first to comment and share your perspective with the community.