{"id":15846,"date":"2019-03-06T13:25:27","date_gmt":"2019-03-06T13:25:27","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=15846"},"modified":"2025-03-26T07:08:13","modified_gmt":"2025-03-26T07:08:13","slug":"linux-dig-command","status":"publish","type":"post","link":"\/in\/tutorials\/linux-dig-command","title":{"rendered":"How to use the Linux dig command"},"content":{"rendered":"<p>The <strong>dig<\/strong> command, short for <strong>domain information groper<\/strong>, is a powerful network tool for querying domain name system (DNS) servers. It helps diagnose and resolve DNS-related problems, essential for maintaining network stability and performance.<\/p><p>This article provides a complete guide on using the <strong>dig<\/strong> command in Linux, from its installation and basic syntax to practical applications. By the end of this guide, you&rsquo;ll know how to use <strong>dig<\/strong> effectively to perform DNS lookups, troubleshoot network issues, and monitor propagations.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Linux-Commands-Cheat-Sheet.pdf\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet-1024x283.png\" alt=\"\" class=\"wp-image-69262\" srcset=\"https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2022\/11\/Linux-cheat-sheet-1536x425.png 1024w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2022\/11\/Linux-cheat-sheet-300x83.png 300w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2022\/11\/Linux-cheat-sheet-150x41.png 150w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2022\/11\/Linux-cheat-sheet-768x212.png 768w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2022\/11\/Linux-cheat-sheet.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-installing-and-setting-up-dig\">Installing and setting up dig<\/h2><p>Before using the <strong>dig<\/strong> command, ensure it&rsquo;s installed on your Linux system. For <a href=\"\/in\/vps-hosting\">Hostinger VPS<\/a> customers, access your server via SSH to install this tool. You can find your login credentials by navigating to the <strong>VPS overview <\/strong>menu in hPanel.<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e0050797321\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"1460\" height=\"535\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/ssh-access-command-on-hpenal-vps-overview-page.png\" alt=\"The SSH access command on hPanel's VPS overview menu\" class=\"wp-image-125827\" srcset=\"https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/ssh-access-command-on-hpenal-vps-overview-page.png 1460w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/ssh-access-command-on-hpenal-vps-overview-page-300x110.png 300w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/ssh-access-command-on-hpenal-vps-overview-page-1024x375.png 1024w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/ssh-access-command-on-hpenal-vps-overview-page-150x55.png 150w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/ssh-access-command-on-hpenal-vps-overview-page-768x281.png 768w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Here are the commands to install <strong>dig<\/strong> on different <a href=\"\/in\/tutorials\/best-linux-distro\">Linux distributions<\/a>, all of which are available on Hostinger VPS plans.<\/p><p><strong>Debian and Ubuntu<\/strong><\/p><pre class=\"wp-block-preformatted\">sudo apt-get update\nsudo apt-get install dnsutils<\/pre><p><strong>CentOS<\/strong><\/p><pre class=\"wp-block-preformatted\">sudo yum install bind-utils<\/pre><p><strong>Fedora<\/strong><\/p><pre class=\"wp-block-preformatted\">sudo dnf install bind-utils<\/pre><p><strong>Arch Linux<\/strong><\/p><pre class=\"wp-block-preformatted\">sudo pacman -S bind<\/pre><p>After that, verify that <strong>dig<\/strong> is installed correctly by checking its version:<\/p><pre class=\"wp-block-preformatted\">dig -v<\/pre><p>The output should look something like this:<\/p><pre class=\"wp-block-preformatted\">DiG 9.16.1-Ubuntu<\/pre><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a href=\"\/in\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner-1024x300.png\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2023\/02\/VPS-hosting-banner.png 1024w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2023\/02\/VPS-hosting-banner-300x88.png 300w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2023\/02\/VPS-hosting-banner-150x44.png 150w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2023\/02\/VPS-hosting-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-dig-command-syntax\">dig command syntax<\/h2><p>The basic syntax of the <strong>dig<\/strong> command is as follows:<\/p><pre class=\"wp-block-preformatted\">dig [server] [name] [type]<\/pre><p>Here&rsquo;s an explanation of each argument:<\/p><ul class=\"wp-block-list\">\n<li><strong>[server] (optional).<\/strong> The IP address or hostname of the DNS server to query. <strong>dig<\/strong> will use the DNS servers listed in <strong>\/etc\/resolv.conf<\/strong> if omitted.<\/li>\n\n\n\n<li><strong>[name].<\/strong> The domain name to query. This is the DNS resource record about which you want information.<\/li>\n\n\n\n<li><strong>[type] (optional).<\/strong> The DNS record type to query, including A, MX, and NS. <strong>dig<\/strong> will query an A record if no type is specified by default.<\/li>\n<\/ul><p>For instance, to query an A record for <strong>example.com<\/strong>, you can run:<\/p><pre class=\"wp-block-preformatted\">dig example.com<\/pre><p>Here&rsquo;s the expected output:<\/p><pre class=\"wp-block-preformatted\">; &lt;&lt;&gt;&gt; DiG 9.16.1-Ubuntu &lt;&lt;&gt;&gt; example.com<br><br>;; global options: +cmd<br><br>;; Got answer:<br><br>;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 12345<br><br>;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1<br><br>;; QUESTION SECTION:<br><br>;example.com. &nbsp; IN&nbsp; A<br><br>;; ANSWER SECTION:<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; A 93.184.216.34<br><br>;; AUTHORITY SECTION:<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; NS ns1.example.com.<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; NS ns2.example.com.<br><br>;; ADDITIONAL SECTION:<br><br>ns1.example.com.&nbsp; 3600&nbsp; IN&nbsp; A 192.0.2.1<br><br>;; Query time: 10 msec<br><br>;; SERVER: 192.0.2.53#53(192.0.2.53)<br><br>;; WHEN: Thu Jul 25 14:00:00 UTC 2024<br><br>;; MSG SIZE&nbsp; rcvd: 123<\/pre><p>Instead of using the <strong>dig <\/strong>command, Hostinger VPS users can ask the <strong>Kodee AI assistant <\/strong>to query information about a domain. For example, check the A records of <strong>example.com<\/strong> like so:<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e0050799d3e\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1024\" height=\"398\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/kodee-queries-a-record-information-of-a-domain-1024x398.png\" alt=\"Kodee queries A record information of a domain name\" class=\"wp-image-124530\" srcset=\"https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/kodee-queries-a-record-information-of-a-domain-1024x398.png 1024w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/kodee-queries-a-record-information-of-a-domain-300x117.png 300w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/kodee-queries-a-record-information-of-a-domain-150x58.png 150w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/kodee-queries-a-record-information-of-a-domain-768x299.png 768w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/kodee-queries-a-record-information-of-a-domain.png 1460w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-dig-command-options\"><strong>dig command options<\/strong><\/h3><p>The <strong>dig<\/strong> command offers several options to customize the DNS queries and outputs. Here are some of the most commonly used ones:<\/p><ul class=\"wp-block-list\">\n<li><strong>+short.<\/strong> Displays only the most relevant information, such as the IP address for an A record.<\/li>\n\n\n\n<li><strong>+noall.<\/strong> Suppresses all sections of the output except those explicitly requested.<\/li>\n\n\n\n<li><strong>+answer.<\/strong> Shows only the answer section of the output. Typically used with <strong>+noall<\/strong>.<\/li>\n\n\n\n<li><strong>+trace.<\/strong> Performs a complete trace of the DNS resolution process from the root servers down to the authoritative servers.<\/li>\n\n\n\n<li><strong>@server.<\/strong> Specifies a different DNS server to query instead of the default one.<\/li>\n\n\n\n<li><strong>-x.<\/strong> Performs a reverse DNS lookup, translating an IP address to a domain name.<\/li>\n\n\n\n<li><strong>+multi.<\/strong> Formats the output to be more human-readable, which is useful when dealing with multiple DNS records.<\/li>\n\n\n\n<li><strong>+nocmd.<\/strong> Omits the initial command line from the output, showing only the results.<\/li>\n\n\n\n<li><strong>+stats.<\/strong> Shows the statistics section, which includes query time and server details.<\/li>\n<\/ul><p>You can also use multiple options in one command to customize the output further. Below is an example of combining <strong>@server<\/strong>, <strong>+short<\/strong>, and <strong>+trace<\/strong> options:<\/p><pre class=\"wp-block-preformatted\">dig @8.8.8.8 example.com +short +trace<\/pre><p>When executed, it displays the following:<\/p><pre class=\"wp-block-preformatted\">; &lt;&lt;&gt;&gt; DiG 9.16.1-Ubuntu &lt;&lt;&gt;&gt; @8.8.8.8 example.com +short +trace<br><br>;; global options: +cmd<br><br>. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 518400&nbsp; IN&nbsp; NS&nbsp; a.root-servers.net.<br><br>. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 518400&nbsp; IN&nbsp; NS&nbsp; b.root-servers.net.<br><br>...<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; A 93.184.216.34<\/pre><h2 class=\"wp-block-heading\" id=\"h-how-to-use-the-dig-command\">How to use the dig command<\/h2><p>This section demonstrates how to use the <strong>dig<\/strong> command for various network administration scenarios.<\/p><h3 class=\"wp-block-heading\" id=\"h-querying-a-specific-dns-record-type\">Querying a specific DNS record type<\/h3><p>Querying a specific DNS record type lets you obtain particular information about a domain, such as its IP address, mail servers, or name servers. Here are different <strong>dig<\/strong> commands to query specific DNS record types:<\/p><p><strong>SOA record<\/strong><\/p><p>The start of authority (SOA) record contains administrative information about the domain, including the primary name server and the domain administrator&rsquo;s registered email.<\/p><pre class=\"wp-block-preformatted\">dig example.com SOA<\/pre><p>Here&rsquo;s the output you should see:<\/p><pre class=\"wp-block-preformatted\">...<br><br>;; QUESTION SECTION:<br><br>;example.com.&nbsp; IN&nbsp; SOA<br><br>;; ANSWER SECTION:<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; SOA ns1.example.com. hostmaster.example.com. 2021071601 3600 1800 1209600 300<br><br>...<\/pre><p><strong>MX record<\/strong><\/p><p>The mail exchange (MX) record specifies the mail servers responsible for receiving emails for the domain, which is vital for setting up and troubleshooting email services.<\/p><pre class=\"wp-block-preformatted\">dig example.com MX<\/pre><p>Running the above command will show the following:<\/p><pre class=\"wp-block-preformatted\">...<br><br>;; QUESTION SECTION:<br><br>;example.com.&nbsp; IN&nbsp; MX<br><br>;; ANSWER SECTION:<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; MX 10 mail.example.com.<br><br>;; ADDITIONAL SECTION:<br><br>mail.example.com.&nbsp; 3600&nbsp; IN&nbsp; A 192.0.2.2<br><br>...<\/pre><p><strong>NS record<\/strong><\/p><p>The name server (NS) record lists the name servers responsible for the domain. It helps you understand the domain&rsquo;s DNS infrastructure.<\/p><pre class=\"wp-block-preformatted\">dig example.com NS<\/pre><p>This command will show an output similar to:<\/p><pre class=\"wp-block-preformatted\">...<br><br>;; QUESTION SECTION:<br><br>;example.com.&nbsp; IN&nbsp; NS<br><br>;; ANSWER SECTION:<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; NS ns1.example.com.<br><br>example.com.&nbsp; 3600&nbsp; 3600&nbsp; IN&nbsp; NS ns2.example.com.<br><br>;; ADDITIONAL SECTION:<br><br>ns1.example.com.&nbsp; 3600&nbsp; IN&nbsp; A 192.0.2.1<br><br>...<\/pre><h3 class=\"wp-block-heading\" id=\"h-querying-a-specific-dns-server\">Querying a specific DNS server<\/h3><p>You can use <strong>dig<\/strong> to ask a particular DNS server for information instead of relying on the default ones configured in your system. It&rsquo;s useful for testing and comparing responses from different DNS servers.<\/p><p><strong>Querying Google&rsquo;s public DNS server<\/strong><\/p><p>Google&rsquo;s public DNS server (<strong>8.8.8.8<\/strong>) is often used for testing and troubleshooting.<\/p><pre class=\"wp-block-preformatted\">dig @8.8.8.8 example.com<\/pre><p>Here&rsquo;s the output:<\/p><pre class=\"wp-block-preformatted\">...<br><br>;; QUESTION SECTION:<br><br>;example.com.&nbsp; IN&nbsp; A<br><br>;; ANSWER SECTION:<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; A 93.184.216.34<br><br>;; AUTHORITY SECTION:<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; NS ns1.example.com.<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; NS ns2.example.com.<br><br>;; ADDITIONAL SECTION:<br><br>ns1.example.com.&nbsp; 3600&nbsp; IN&nbsp; A 192.0.2.1<br><br>...<\/pre><p><strong>Querying an authoritative name server<\/strong><\/p><p>Authoritative name servers provide the definitive answer for DNS queries about domains, ensuring you get the most accurate response.<\/p><pre class=\"wp-block-preformatted\">dig @ns1.example.com example.com<\/pre><p>If your configurations are correct, you&rsquo;ll see an output similar to the previous one.<\/p><h3 class=\"wp-block-heading\" id=\"h-tracing-the-dns-path\">Tracing the DNS path<\/h3><p>Tracing the DNS path involves following a DNS query from your computer to the authoritative name server. This process lets you see the route queries take to the final DNS server.<\/p><p>To trace the DNS path, append the <strong>+trace<\/strong> option to your command like this:<\/p><pre class=\"wp-block-preformatted\">dig example.com +trace<\/pre><p>The <strong>dig<\/strong> output shows the DNS servers involved at each step:<\/p><pre class=\"wp-block-preformatted\">. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 518400&nbsp; IN&nbsp; &nbsp; &nbsp; NS&nbsp; &nbsp; &nbsp; a.root-servers.net.<br><br>. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 518400&nbsp; IN&nbsp; &nbsp; &nbsp; NS&nbsp; &nbsp; &nbsp; b.root-servers.net.<br><br>;; Received 512 bytes from 192.0.2.1#53(192.0.2.1) in 5 ms<br><br>example.com.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3600&nbsp; &nbsp; IN&nbsp; &nbsp; &nbsp; NS&nbsp; &nbsp; &nbsp; ns1.example.com.<br><br>example.com.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3600&nbsp; &nbsp; IN&nbsp; &nbsp; &nbsp; NS&nbsp; &nbsp; &nbsp; ns2.example.com.<br><br>;; Received 200 bytes from 192.0.2.1#53(192.0.2.1) in 10 ms<br><br>example.com.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3600&nbsp; &nbsp; IN&nbsp; &nbsp; &nbsp; A &nbsp; &nbsp; &nbsp; 93.184.216.34<br><br>;; Received 100 bytes from 192.0.2.2#53(192.0.2.2) in 15 ms<\/pre><h3 class=\"wp-block-heading\" id=\"h-displaying-only-the-answer-section\">Displaying only the answer section<\/h3><p>Using the <strong>dig<\/strong> command, you can filter the output to show cleaner and more readable information while eliminating unnecessary details, making it quicker to analyze results.<\/p><p>Use the <strong>+noall<\/strong> and <strong>+answer<\/strong> options together in your <strong>dig<\/strong> command, for example:<\/p><pre class=\"wp-block-preformatted\">dig example.com +noall +answer<\/pre><p>This provides a clean and concise result showing just the queried domain&rsquo;s IP address:<\/p><pre class=\"wp-block-preformatted\">example.com.&nbsp; 3600&nbsp; IN&nbsp; A 93.184.216.34<\/pre><h3 class=\"wp-block-heading\" id=\"h-formatting-output\">Formatting output<\/h3><p>Similar to displaying only the answer section, formatting output lets you customize how the results are displayed to make them more readable and easier to analyze. Here are some command examples for use:<\/p><p><strong>Using +short<\/strong><\/p><p>This option summarizes the query results. For instance:<\/p><pre class=\"wp-block-preformatted\">dig example.com +short<\/pre><p>You should see the following output:<\/p><pre class=\"wp-block-preformatted\">93.184.216.34<\/pre><p><strong>Using +multi<\/strong><\/p><p>As the name suggests, <strong>+multi <\/strong>displays multiple records in a more readable format:<\/p><pre class=\"wp-block-preformatted\">dig example.com +multi<\/pre><p>Here&rsquo;s the output:<\/p><pre class=\"wp-block-preformatted\">example.com.&nbsp; 3600&nbsp; IN&nbsp; A &nbsp; 93.184.216.34<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; NS&nbsp; ns1.example.com.<br><br>3600&nbsp; IN&nbsp; NS&nbsp; ns2.example.com.<\/pre><p><strong>Using +nocmd<\/strong><\/p><p>Use <strong>+nocmd<\/strong> in your command to show only the main results:<\/p><pre class=\"wp-block-preformatted\">dig example.com +nocmd<\/pre><p>When executed, it displays:<\/p><pre class=\"wp-block-preformatted\">;; QUESTION SECTION:<br><br>;example.com.&nbsp; IN&nbsp; A<br><br>;; ANSWER SECTION:<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; A 93.184.216.34<\/pre><p><strong>Using +comments<\/strong><\/p><p>With <strong>+comments<\/strong>, you can show or hide comment lines in the output. For example, to hide comments, run:<\/p><pre class=\"wp-block-preformatted\">dig example.com +nocmd +noall +answer +nocomments<\/pre><p>The above command will show:<\/p><pre class=\"wp-block-preformatted\">example.com.&nbsp; 3600&nbsp; IN&nbsp; A 93.184.216.34<\/pre><h3 class=\"wp-block-heading\" id=\"h-performing-reverse-dns-lookup\">Performing reverse DNS lookup<\/h3><p>A reverse lookup converts an IP address into a domain name, the opposite of the more common forward DNS lookup. This helps verify that the IP address is correctly mapped to a specific domain name.<\/p><p>Here&rsquo;s an example of performing a reverse DNS lookup:<\/p><pre class=\"wp-block-preformatted\">dig -x 93.184.216.34<\/pre><p>You&rsquo;ll see an output similar to:<\/p><pre class=\"wp-block-preformatted\">...<br><br>;; QUESTION SECTION:<br><br>;34.216.184.93.in-addr.arpa. IN&nbsp; PTR<br><br>;; ANSWER SECTION:<br><br>34.216.184.93.in-addr.arpa. 3600&nbsp; IN&nbsp; PTR example.com.<br><br>...<\/pre><p>Please note if a PTR record is not defined for an IP address, then it&rsquo;s not possible to do a reverse DNS lookup since the PTR record points to the domain or hostname.<\/p><h3 class=\"wp-block-heading\" id=\"h-executing-batch-queries\">Executing batch queries<\/h3><p>You can also use <strong>dig<\/strong> to execute multiple DNS lookups in a single command. It helps query information about several domain names or IP addresses, saving time and simplifying the process.<\/p><p>To run batch queries, follow these steps:<\/p><ol class=\"wp-block-list\">\n<li>Create a file named <strong>domains.txt<\/strong> or any name you prefer using the <a href=\"\/in\/tutorials\/how-to-install-and-use-nano-text-editor\">nano text editor<\/a>:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">nano domains.txt<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Add the IP addresses or domains you want to query, one per line:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">example1.com<br><br>example2.com<br><br>example3.com<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Save your edits and exit <strong>nano<\/strong> by pressing <strong>Ctrl + X &rarr; Y &rarr; Enter<\/strong>.<\/li>\n\n\n\n<li>Run <strong>dig<\/strong> with the <strong>-f<\/strong> option followed by your file&rsquo;s name:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">dig -f domains.txt<\/pre><p>When executed, the command shows:<\/p><pre class=\"wp-block-preformatted\">...<br><br>;; QUESTION SECTION:<br><br>;example1.com.&nbsp; IN&nbsp; A<br><br>;; ANSWER SECTION:<br><br>example1.com.&nbsp; 3600&nbsp; IN&nbsp; A 93.184.216.34<br><br>;; AUTHORITY SECTION:<br><br>example1.com.&nbsp; 3600&nbsp; IN&nbsp; NS ns1.example1.com.<br><br>example1.com.&nbsp; 3600&nbsp; IN&nbsp; NS ns2.example1.com.<br><br>;; ADDITIONAL SECTION:<br><br>ns1.example1.com.&nbsp; 3600&nbsp; IN&nbsp; A 192.0.2.1<br><br>...<br><br>;; QUESTION SECTION:<br><br>;example2.com.&nbsp; IN&nbsp; A<br><br>;; ANSWER SECTION:<br><br>example2.com.&nbsp; 3600&nbsp; IN&nbsp; A 93.184.216.35<br><br>;; AUTHORITY SECTION:<br><br>example2.com.&nbsp; 3600&nbsp; IN&nbsp; NS ns1.example2.com.<br><br>example2.com.&nbsp; 3600&nbsp; IN&nbsp; NS ns2.example2.com.<br><br>;; ADDITIONAL SECTION:<br><br>ns1.example2.com.&nbsp; 3600&nbsp; IN&nbsp; A 192.0.2.2<br><br>...<br><br>;; QUESTION SECTION:<br><br>;example3.com.&nbsp; IN&nbsp; A<br><br>;; ANSWER SECTION:<br><br>example3.com.&nbsp; 3600&nbsp; IN&nbsp; A 93.184.216.36<br><br>;; AUTHORITY SECTION:<br><br>example3.com.&nbsp; 3600&nbsp; IN&nbsp; NS ns1.example3.com.<br><br>example3.com.&nbsp; 3600&nbsp; IN&nbsp; NS ns2.example3.com.<br><br>;; ADDITIONAL SECTION:<br><br>ns1.example3.com.&nbsp; 3600&nbsp; IN&nbsp; A 192.0.2.3<\/pre><h3 class=\"wp-block-heading\" id=\"h-verifying-dnssec\">Verifying DNSSEC<\/h3><p>DNS security extensions, or DNSSEC, are a set of protocols that secure the DNS lookup process. It ensures that the responses are authentic and haven&rsquo;t been tampered with. Verifying DNSSEC helps protect against DNS spoofing attacks.<\/p><p>To verify DNSSEC with the <strong>dig<\/strong> command, add the <strong>+dnssec<\/strong> option:<\/p><pre class=\"wp-block-preformatted\">dig example.com +dnssec<\/pre><p>The output includes RRSIG records in the <strong>ANSWER<\/strong> and <strong>AUTHORITY<\/strong> sections:<\/p><pre class=\"wp-block-preformatted\">...<br><br>;; QUESTION SECTION:<br><br>;example.com.&nbsp; IN&nbsp; A<br><br>;; ANSWER SECTION:<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; A 93.184.216.34<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; RRSIG&nbsp; A 13 2 3600 (<br><br>20240301000000 20240215000000 12345 example.com.<br><br>hT+pV8JZfCh3UOjP4xB1C2YJmtD5efcd )<br><br>;; AUTHORITY SECTION:<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; NS&nbsp; ns1.example.com.<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; NS&nbsp; ns2.example.com.<br><br>example.com.&nbsp; 3600&nbsp; IN&nbsp; RRSIG&nbsp; NS 13 2 3600 (<br><br>20240301000000 20240215000000 12345 example.com.<br><br>kd9K8vNlF8cD\/B8ejq8G8C9Zp7L )<br><br>;; ADDITIONAL SECTION:<br><br>ns1.example.com.&nbsp; 3600&nbsp; IN&nbsp; A 192.0.2.1<br><br>ns1.example.com.&nbsp; 3600&nbsp; IN&nbsp; RRSIG&nbsp; A 13 2 3600 (<br><br>20240301000000 20240215000000 12345 example.com.<br><br>y6R\/B9elK5dQ\/L5gRk9F4O0aP8g )<br><br>...<\/pre><h2 class=\"wp-block-heading\" id=\"h-practical-dig-applications\">Practical dig applications<\/h2><p>Once you&rsquo;ve learned the basics, it&rsquo;s time to explore some practical <strong>dig<\/strong> command applications.<\/p><p><strong>Troubleshooting DNS issues<\/strong><\/p><p>Using the <strong>dig<\/strong> command to diagnose DNS problems helps you effectively identify and resolve network issues. Here are general steps for troubleshooting DNS issues with this command:<\/p><ol class=\"wp-block-list\">\n<li>Check the DNS resolution by verifying if a domain name resolves correctly:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">dig example.com<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Ensure the domain&rsquo;s name servers are correctly configured:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">dig example.com NS<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Identify where DNS resolution might be failing by tracing the entire DNS lookup path:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">dig example.com +trace<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Verify the DNSSEC settings to see if the RRSIG records are present:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">dig example.com +dnssec<\/pre><ol start=\"5\" class=\"wp-block-list\">\n<li>Make sure that an IP address resolves to the correct domain name:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">dig -x 93.184.216.34<\/pre><ol start=\"6\" class=\"wp-block-list\">\n<li>To fix specific services like email, check the relevant DNS records. For example:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">dig example.com MX<\/pre><p>Pay attention to each output and make sure the <strong>ANSWER<\/strong> sections are correct.<\/p><p><strong>Monitoring DNS propagation<\/strong><\/p><p>Monitoring DNS propagation involves checking the DNS change status across different servers. It ensures that DNS record updates have been successfully propagated throughout the web.<\/p><p>Follow these instructions to verify DNS propagation:<\/p><ol class=\"wp-block-list\">\n<li>Use the <strong>@server<\/strong> option to query a specific DNS server, such as Google&rsquo;s public DNS server:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">dig @8.8.8.8 example.com<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Query different DNS servers to compare their responses. For Cloudflare&rsquo;s server, run:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">dig @1.1.1.1 example.com<\/pre><p>If the <strong>ANSWER<\/strong> sections from different servers match, the DNS changes have propagated successfully. Otherwise, some servers may still need to update their records. You can check the propagation status periodically.<\/p><p><strong>Performance testing<\/strong><\/p><p>Measuring DNS response times is essential for assessing your DNS servers&rsquo; performance. This lets you identify slowdowns or issues affecting your network&rsquo;s speed and reliability.<\/p><p>Here&rsquo;s how to measure DNS response times:<\/p><ol class=\"wp-block-list\">\n<li>Run the basic <strong>dig<\/strong> command. Focus on the output&rsquo;s <strong>Query time<\/strong> field, which indicates the time taken to get a DNS server response:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">dig example.com<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Query different DNS servers to compare their response times. This helps identify which servers are performing better:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">dig @8.8.8.8 example.com<br><br>dig @1.1.1.1 example.com<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Use the <strong>+stats<\/strong> option for additional statistics about query times and server details:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">dig example.com +stats<\/pre><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>In this article, we covered the essential uses of the Linux <strong>dig<\/strong> command, from fundamental DNS lookups to more advanced queries and troubleshooting methods. In addition, mastering <strong>dig<\/strong> can enhance your network management skills.<\/p><p>Practice the command examples in this guide to get the most out of <strong>dig<\/strong>. Experimenting with different options allows you to comprehend DNS&rsquo;s inner workings better and optimize network performance.<\/p><p>If you have any questions or want to share your experience with <strong>dig<\/strong> commands, leave a comment below.<\/p><h2 class=\"wp-block-heading\" id=\"h-dig-command-faq\">dig command FAQ<\/h2><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1722417452987\"><h3 class=\"schema-faq-question\">What is the dig command used for?<\/h3> <p class=\"schema-faq-answer\">The <strong>dig<\/strong> command is used to query DNS name servers. It retrieves DNS information about numerous records, such as A, MX, and NS, helping diagnose and resolve network-related problems.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1722417457230\"><h3 class=\"schema-faq-question\">How does the dig command work?<\/h3> <p class=\"schema-faq-answer\">The <strong>dig<\/strong> command works by sending a DNS query to the specified server. It then displays the response, which includes information about the queried domain&rsquo;s DNS records, allowing network administrators to fix issues.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1722417463161\"><h3 class=\"schema-faq-question\">What are some common uses of the dig command?<\/h3> <p class=\"schema-faq-answer\">The dig command is commonly used to perform DNS lookups, query specific record types, trace DNS resolution paths, verify DNSSEC, and troubleshoot propagation and resolution issues.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>The dig command, short for domain information groper, is a powerful network tool for querying domain name system (DNS) servers. It helps diagnose and resolve DNS-related problems, essential for maintaining network stability and performance. This article provides a complete guide on using the dig command in Linux, from its installation and basic syntax to practical [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/in\/tutorials\/linux-dig-command\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":411,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"","rank_math_description":"","rank_math_focus_keyword":"","footnotes":""},"categories":[22644,22640],"tags":[],"class_list":["post-15846","post","type-post","status-publish","format-standard","hentry","category-managing-monitoring-and-security","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/linux-dig-command","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/comment-utiliser-la-commande-dig-sous-linux","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/comando-dig-linux","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/linux-dig-command","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/linux-dig-command","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/linux-dig-command","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/que-son-hooks-wordpress-12","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/que-son-hooks-wordpress-12","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/comando-dig-linux","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/linux-dig-command","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/linux-dig-command","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/linux-dig-command","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/linux-dig-command","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/posts\/15846","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/users\/411"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/comments?post=15846"}],"version-history":[{"count":20,"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/posts\/15846\/revisions"}],"predecessor-version":[{"id":125828,"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/posts\/15846\/revisions\/125828"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/media?parent=15846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/categories?post=15846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/tags?post=15846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}