{"id":5230,"date":"2021-04-07T09:34:45","date_gmt":"2021-04-07T09:34:45","guid":{"rendered":"https:\/\/chemicloud.com\/kb\/?post_type=ht_kb&#038;p=5230"},"modified":"2024-10-08T08:10:25","modified_gmt":"2024-10-08T08:10:25","slug":"dig-command","status":"publish","type":"ht_kb","link":"https:\/\/chemicloud.com\/kb\/article\/dig-command\/","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&#8217;ll explain how to read the output of the dig command and how to use the command.<\/p>\n<h2 id=\"how-to-use-the-dig-command\">How to use the DIG command<\/h2>\n<h3 id=\"what-can-i-learn-using-the-dig-command\">What can I learn using the dig command?<\/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\">Run the Command<\/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&#8217;t familiar with connecting to your hosting account with SSH, click <a href=\"https:\/\/chemicloud.com\/kb\/article\/log-account-via-ssh\/\" target=\"_blank\" rel=\"noopener\">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&#8217;re querying.<\/p>\n<p class=\"p1\"><b>Struggling with DNS issues? ChemiCloud is the hosting solution designed to save you time! <\/b><span class=\"s1\">\ud83e\udd13<\/span><b> Check out our <\/b><a href=\"https:\/\/chemicloud.com\/pricing#60b65e4e63b58\"><span class=\"s2\"><b>web hosting <\/b><\/span><\/a><b>plans!<\/b><\/p>\n<h3 id=\"examine-the-output\">Examine the Output<\/h3>\n<pre>[yourcpusercc@rs2-dal ~]$ dig cchostingdemos.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; cchostingdemos.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;cchostingdemos.com. IN A\r\n\r\n;; ANSWER SECTION:\r\ncchostingdemos.com. 300 IN A 104.21.69.5\r\ncchostingdemos.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;cchostingdemos.com. IN A<\/pre>\n<p>The answer section is where the answer to our query is given.<\/p>\n<pre>;; ANSWER SECTION:\r\ncchostingdemos.com. 300 IN A 104.21.69.5\r\ncchostingdemos.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\">Quick dig commands you should know<\/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.chemicloud.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&#8217;s a wrap! Now you know how to master the DIG command using your terminal.<\/p>\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&#8230;.<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"ht-kb-category":[188],"ht-kb-tag":[],"class_list":["post-5230","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-support-resources"],"_links":{"self":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb\/5230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/comments?post=5230"}],"version-history":[{"count":6,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb\/5230\/revisions"}],"predecessor-version":[{"id":8250,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb\/5230\/revisions\/8250"}],"wp:attachment":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/media?parent=5230"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb-category?post=5230"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb-tag?post=5230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}