{"id":281,"date":"2024-06-02T16:42:39","date_gmt":"2024-06-02T16:42:39","guid":{"rendered":"https:\/\/zalvis.com\/docs\/?p=281"},"modified":"2024-06-02T16:43:00","modified_gmt":"2024-06-02T16:43:00","slug":"dig-command","status":"publish","type":"post","link":"https:\/\/zalvis.com\/docs\/dig-command.html","title":{"rendered":"How To Use The DIG Command"},"content":{"rendered":"<p>The DIG command is a tool for querying DNS nameservers for information about host addresses, mail exchange servers, nameservers, and other related information. This tool can be used from any Linux\/Unix or macOS operating system.<\/p>\n<p>The most typical use of the dig command is to simply query a single host.<\/p>\n<p>In this KB article, we\u2019ll explain how to read the output of the dig command and how to use the command.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_81 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/zalvis.com\/docs\/dig-command.html\/#How_To_Use_The_DIG_Command\" >How To Use The DIG Command<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/zalvis.com\/docs\/dig-command.html\/#What_Can_I_Learn_Using_The_Dig_Command\" >What Can I Learn Using The Dig Command?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/zalvis.com\/docs\/dig-command.html\/#Run_The_Command\" >Run The Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/zalvis.com\/docs\/dig-command.html\/#Examine_The_Output\" >Examine The Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/zalvis.com\/docs\/dig-command.html\/#Quick_Dig_Commands_You_Should_Know\" >Quick Dig Commands You Should Know<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 id=\"how-to-use-the-dig-command\"><span class=\"ez-toc-section\" id=\"How_To_Use_The_DIG_Command\"><\/span>How To Use The DIG Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3 id=\"what-can-i-learn-using-the-dig-command\"><span class=\"ez-toc-section\" id=\"What_Can_I_Learn_Using_The_Dig_Command\"><\/span>What Can I Learn Using The Dig Command?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>dig will let you perform any valid DNS query, the most common of which are:<\/p>\n<ul>\n<li>A (the IP address)<\/li>\n<li>TXT (text annotations)<\/li>\n<li>MX (mail exchanges)<\/li>\n<li>NS (nameservers)<\/li>\n<\/ul>\n<h3 id=\"run-the-command\"><span class=\"ez-toc-section\" id=\"Run_The_Command\"><\/span>Run The Command<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ol>\n<li>First, open your SSH client and open a connection to your hosting account or any system where you have a console\/command line in which you can input commands. If you aren\u2019t familiar with connecting to your hosting account with SSH, click <a href=\"https:\/\/zalvis.com\/docs\/?s=FTP\">here<\/a> to review our Knowledgebase Article on the subject.<\/li>\n<li>Once you have your connection open, enter the command as:<\/li>\n<\/ol>\n<p>dig domain.tld where domain.tld is the domain and extension you\u2019re querying.<\/p>\n<p class=\"p1\"><b>Struggling with DNS issues? Zalvis is the hosting solution designed to save you time! <\/b><span class=\"s1\">\ud83e\udd13 <\/span><b>Check out our <\/b><a href=\"https:\/\/zalvis.com\/web-hosting\"><span class=\"s2\"><b>web hosting <\/b><\/span><\/a><b>plans!<\/b><\/p>\n<h3 id=\"examine-the-output\"><span class=\"ez-toc-section\" id=\"Examine_The_Output\"><\/span>Examine The Output<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre>[yourcpusercc@rs2-dal ~]$ dig zalvis.com\r\n\r\n; &lt;&lt;&gt;&gt; DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.4 &lt;&lt;&gt;&gt; zalvis.com\r\n;; global options: +cmd\r\n;; Got answer:\r\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 52628\r\n;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1\r\n\r\n;; OPT PSEUDOSECTION:\r\n; EDNS: version: 0, flags:; udp: 4096\r\n;; QUESTION SECTION:\r\n;zalvis.com. IN A\r\n\r\n;; ANSWER SECTION:\r\nzalvis.com. 300 IN A 104.21.69.5\r\nzalvis.com. 300 IN A 172.67.202.37\r\n\r\n;; Query time: 7 msec\r\n;; SERVER: 198.58.107.5#53(198.58.107.5)\r\n;; WHEN: Tue Apr 06 22:21:26 EDT 2021\r\n;; MSG SIZE rcvd: 79<\/pre>\n<p>The opening section of the output tells us a little bit about itself:<\/p>\n<pre>; &lt;&lt;&gt;&gt; DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.4 &lt;&lt;&gt;&gt; cchostingdemos.com<\/pre>\n<p>&nbsp;<\/p>\n<p>The Got answer section tells us some technical details about the answer received from the DNS Server.<\/p>\n<pre>;; Got answer:\r\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 52628\r\n;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1<\/pre>\n<p>The Question section serves to remind us of our query. The default query is for an Internet address (A).<\/p>\n<pre>;; QUESTION SECTION:\r\n;zalvis.com. IN A<\/pre>\n<p>The answer section is where the answer to our query is given.<\/p>\n<pre>;; ANSWER SECTION:\r\nzalvis.com. 300 IN A 104.21.69.5\r\nzalvis.com. 300 IN A 172.67.202.37<\/pre>\n<p>The final section of the default output contains statistics about the query.<\/p>\n<pre>;; Query time: 7 msec\r\n;; SERVER: 198.58.107.5#53(198.58.107.5)\r\n;; WHEN: Tue Apr 06 22:21:26 EDT 2021\r\n;; MSG SIZE rcvd: 79<\/pre>\n<h3 id=\"quick-dig-commands-you-should-know\"><span class=\"ez-toc-section\" id=\"Quick_Dig_Commands_You_Should_Know\"><\/span>Quick Dig Commands You Should Know<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>A quick way to get just the answer and not the fluff around it is to run:<\/li>\n<\/ul>\n<pre>dig domain.tld +short<\/pre>\n<ul>\n<li>Use this command to get the addresses for a domain:<\/li>\n<\/ul>\n<pre>dig domain.tld A +noall +answer<\/pre>\n<ul>\n<li>Use this command to get a list of all of the mail servers for a domain:<\/li>\n<\/ul>\n<pre>dig domain.tld MX +noall +answer<\/pre>\n<ul>\n<li>Use this command to get a list of authoritative DNS servers for a domain:<\/li>\n<\/ul>\n<pre>dig domain.tld NS +noall +answer<\/pre>\n<ul>\n<li>Use this command to get a list of all of the above in one convenient set of results:<\/li>\n<\/ul>\n<pre>dig domain.tld ANY +noall +answer<\/pre>\n<ul>\n<li>Use this command to query A record of a domain using a specific nameserver:<\/li>\n<\/ul>\n<pre>dig A domain.tld @ns1.zalvis.com +short<\/pre>\n<ul>\n<li>Use the following to trace the path taken:<\/li>\n<\/ul>\n<pre>dig domain.tld +trace<\/pre>\n<p>That\u2019s a wrap! Now you know how to master the DIG command using your terminal.<\/p>\n<div class=\"srhmx69de710c53fc7\" >If you enjoyed this article, then you\u2019ll love Zalvis's Cloud Hosting platform. Turbocharge your website and get 24\/7 support from our veteran team. Our world-class hosting infrastructure focuses on auto-scaling, performance, and security. Let us show you the Zalvis difference! <a href=\"https:\/\/zalvis.com\/\">Check out our services.<\/a><\/div><style type=\"text\/css\">\r\n@media screen and (min-width: 1201px) {\r\n.srhmx69de710c53fc7 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 993px) and (max-width: 1200px) {\r\n.srhmx69de710c53fc7 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 769px) and (max-width: 992px) {\r\n.srhmx69de710c53fc7 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 768px) and (max-width: 768px) {\r\n.srhmx69de710c53fc7 {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (max-width: 767px) {\r\n.srhmx69de710c53fc7 {\r\ndisplay: block;\r\n}\r\n}\r\n<\/style>\r\n","protected":false},"excerpt":{"rendered":"<p>The DIG command is a tool for querying DNS nameservers for information about host addresses, mail exchange servers, nameservers, and other related information. This tool can be used from any Linux\/Unix or macOS operating system. The most typical use of the dig command is to simply query a single host. In this KB article, we\u2019ll [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-281","post","type-post","status-publish","format-standard","hentry","category-support-faqs"],"_links":{"self":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/comments?post=281"}],"version-history":[{"count":2,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/281\/revisions"}],"predecessor-version":[{"id":283,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/281\/revisions\/283"}],"wp:attachment":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/media?parent=281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/categories?post=281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/tags?post=281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}