{"id":12601,"date":"2019-03-28T03:26:34","date_gmt":"2019-03-28T03:26:34","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12601"},"modified":"2019-03-28T03:26:34","modified_gmt":"2019-03-28T03:26:34","slug":"10-linux-dig-domain-information-groper-commands-to-query-dns","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/10-linux-dig-domain-information-groper-commands-to-query-dns\/","title":{"rendered":"10 Linux Dig (Domain Information Groper) Commands to Query DNS"},"content":{"rendered":"<p>In our last article we have showed you the most used\u00a0<a href=\"https:\/\/www.tecmint.com\/8-linux-nslookup-commands-to-troubleshoot-dns-domain-name-server\/\" target=\"_blank\" rel=\"noopener\">8 Nslookup commands<\/a>\u00a0with their examples, now here we come with another command line tool called\u00a0<strong>Dig<\/strong>, which is much similar to Linux\u00a0<strong>Nslookup<\/strong>\u00a0tool. We will see the usage of dig command closely with their examples as shown below.<\/p>\n<div id=\"attachment_793\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Dig-Command-Examples1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-793\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Dig-Command-Examples1.png\" alt=\"Linux Dig Command Examples\" width=\"300\" height=\"194\" aria-describedby=\"caption-attachment-793\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-793\" class=\"wp-caption-text\">Linux Dig Command Examples<\/p>\n<\/div>\n<p><strong>Dig<\/strong>\u00a0stands for (<strong>Domain Information Groper<\/strong>) is a network administration command-line tool for querying\u00a0<strong>Domain Name System<\/strong>\u00a0(<strong>DNS<\/strong>) name servers. It is useful for verifying and troubleshooting\u00a0<strong>DNS<\/strong>\u00a0problems and also to perform\u00a0<strong>DNS<\/strong>\u00a0lookups and displays the answers that are returned from the name server that were queried. dig is part of the BIND domain name server software suite. dig command replaces older tool such as\u00a0<strong>nslookup<\/strong>\u00a0and the host. dig tool is available in major Linux distributions.<br \/>\n<span id=\"more-786\"><\/span><\/p>\n<h4>1. Query Domain \u201cA\u201d Record<\/h4>\n<pre><strong># dig yahoo.com<\/strong>; &lt;&lt;&gt;&gt; DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 &lt;&lt;&gt;&gt; yahoo.com\r\n;; global options: +cmd\r\n;; Got answer:\r\n;; -&gt;&gt;HEADER&lt;<\/pre>\n<p>Above command causes dig to look up the\u00a0<strong>\u201cA\u201d<\/strong>\u00a0record for the domain name\u00a0<strong>yahoo.com<\/strong>. Dig command reads the\u00a0<strong>\/etc\/resolv.conf<\/strong>\u00a0file and querying the\u00a0<strong>DNS<\/strong>\u00a0servers listed there. The response from the<strong>\u00a0DNS<\/strong>\u00a0server is what dig displays.<\/p>\n<h5>Let us understand the output of the commands:<\/h5>\n<ol>\n<li>Lines beginning with\u00a0<strong>;<\/strong>\u00a0are comments not part of the information.<\/li>\n<li>The first line tell us the version of dig (<strong>9.8.2<\/strong>) command.<\/li>\n<li>Next, dig shows the header of the response it received from the\u00a0<strong>DNS<\/strong>\u00a0server<\/li>\n<li>Next comes the question section, which simply tells us the query, which in this case is a query for the\u00a0<strong>\u201cA\u201d<\/strong>record of\u00a0<strong>yahoo.com<\/strong>. The\u00a0<strong>IN<\/strong>\u00a0means this is an Internet lookup (in the Internet class).<\/li>\n<li>The answer section tells us that\u00a0<strong>yahoo.com<\/strong>\u00a0has the\u00a0<strong>IP<\/strong>\u00a0address\u00a0<strong>72.30.38.140<\/strong><\/li>\n<li>Lastly there are some stats about the query. You can turn off these stats using the\u00a0<strong>+nostats<\/strong>\u00a0option.<\/li>\n<\/ol>\n<h4>2. Query Domain \u201cA\u201d Record with +short<\/h4>\n<p>By default dig is quite verbose. One way to cut down the output is to use the\u00a0<strong>+short<\/strong>\u00a0option. which will drastically cut the output as shown below.<\/p>\n<pre><strong># dig yahoo.com +short<\/strong>\r\n\r\n98.139.183.24\r\n72.30.38.140\r\n98.138.253.109<\/pre>\n<p><strong>Note:<\/strong>\u00a0By default dig looks for the\u00a0<strong>\u201cA\u201d<\/strong>\u00a0record of the domain specified, but you can specify other records also. The\u00a0<strong>MX<\/strong>\u00a0or\u00a0<strong>Mail eXchange<\/strong>\u00a0record tells mail servers how to route the email for the domain. Likewise\u00a0<strong>TTL<\/strong>,\u00a0<strong>SOA<\/strong>\u00a0etc.<\/p>\n<h4>3. Querying MX Record for Domain<\/h4>\n<p>Querying different types of DNS resource records only.<\/p>\n<pre><strong># dig yahoo.com MX<\/strong>\r\n\r\n; &lt;&gt; DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 &lt;&gt; yahoo.com MX\r\n;; global options: +cmd\r\n;; Got answer:\r\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 31450\r\n;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 24\r\n\r\n;; QUESTION SECTION:\r\n;yahoo.com.                     IN      MX\r\n\r\n;; ANSWER SECTION:\r\nyahoo.com.              33      IN      MX      1 mta6.am0.yahoodns.net.\r\nyahoo.com.              33      IN      MX      1 mta7.am0.yahoodns.net.\r\nyahoo.com.              33      IN      MX      1 mta5.am0.yahoodns.net.<\/pre>\n<h4>4. Querying SOA Record for Domain<\/h4>\n<pre><strong># dig yahoo.com SOA<\/strong>\r\n\r\n; &lt;&gt; DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 &lt;&gt; yahoo.com SOA\r\n;; global options: +cmd\r\n;; Got answer:\r\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 2197\r\n;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 7, ADDITIONAL: 7\r\n\r\n;; QUESTION SECTION:\r\n;yahoo.com.                     IN      SOA\r\n\r\n;; ANSWER SECTION:\r\nyahoo.com.              1800    IN      SOA     ns1.yahoo.com. hostmaster.yahoo-inc.com. 2012081409 3600 300 1814400 600<\/pre>\n<h4>5. Querying TTL Record for Domain<\/h4>\n<pre><strong># dig yahoo.com TTL<\/strong>\r\n\r\n; &lt;&gt; DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 &lt;&gt; yahoo.com TTL\r\n;; global options: +cmd\r\n;; Got answer:\r\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 56156\r\n;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0\r\n\r\n;; QUESTION SECTION:\r\n;yahoo.com.                     IN      A\r\n\r\n;; ANSWER SECTION:\r\nyahoo.com.              3589    IN      A       98.138.253.109\r\nyahoo.com.              3589    IN      A       98.139.183.24\r\nyahoo.com.              3589    IN      A       72.30.38.140<\/pre>\n<h4>6. Querying only answer section<\/h4>\n<pre><strong># dig yahoo.com +nocomments +noquestion +noauthority +noadditional +nostats<\/strong>\r\n\r\n; &lt;&lt;&gt;&gt; DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 &lt;&lt;&gt;&gt; yahoo.com +nocomments +noquestion +noauthority +noadditional +nostats\r\n;; global options: +cmd\r\nyahoo.com.              3442    IN      A       72.30.38.140\r\nyahoo.com.              3442    IN      A       98.138.253.109\r\nyahoo.com.              3442    IN      A       98.139.183.24<\/pre>\n<h4>7. Querying ALL DNS Records Types<\/h4>\n<pre><strong># dig yahoo.com ANY +noall +answer<\/strong>\r\n\r\n; &lt;&lt;&gt;&gt; DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 &lt;&lt;&gt;&gt; yahoo.com ANY +noall +answer\r\n;; global options: +cmd\r\nyahoo.com.              3509    IN      A       72.30.38.140\r\nyahoo.com.              3509    IN      A       98.138.253.109\r\nyahoo.com.              3509    IN      A       98.139.183.24\r\nyahoo.com.              1709    IN      MX      1 mta5.am0.yahoodns.net.\r\nyahoo.com.              1709    IN      MX      1 mta6.am0.yahoodns.net.\r\nyahoo.com.              1709    IN      MX      1 mta7.am0.yahoodns.net.\r\nyahoo.com.              43109   IN      NS      ns2.yahoo.com.\r\nyahoo.com.              43109   IN      NS      ns8.yahoo.com.\r\nyahoo.com.              43109   IN      NS      ns3.yahoo.com.\r\nyahoo.com.              43109   IN      NS      ns1.yahoo.com.\r\nyahoo.com.              43109   IN      NS      ns4.yahoo.com.\r\nyahoo.com.              43109   IN      NS      ns5.yahoo.com.\r\nyahoo.com.              43109   IN      NS      ns6.yahoo.com.<\/pre>\n<h4>8. DNS Reverse Look-up<\/h4>\n<p>Querying\u00a0<strong>DNS<\/strong>\u00a0Reverse Look-up. Only display answer section with using\u00a0<strong>+short<\/strong>.<\/p>\n<pre><strong># dig -x 72.30.38.140 +short<\/strong>\r\n\r\nir1.fp.vip.sp2.yahoo.com.<\/pre>\n<h4>9. Querying Multiple DNS Records<\/h4>\n<p>Query multiple website\u2019s DNS specific query viz.\u00a0<strong>MX<\/strong>,\u00a0<strong>NS<\/strong>\u00a0etc. records.<\/p>\n<pre><strong># dig yahoo.com mx +noall +answer redhat.com ns +noall +answer<\/strong>\r\n\r\n; &lt;&lt;&gt;&gt; DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 &lt;&lt;&gt;&gt; yahoo.com mx +noall +answer redhat.com ns +noall +answer\r\n;; global options: +cmd\r\nyahoo.com.              1740    IN      MX      1 mta6.am0.yahoodns.net.\r\nyahoo.com.              1740    IN      MX      1 mta7.am0.yahoodns.net.\r\nyahoo.com.              1740    IN      MX      1 mta5.am0.yahoodns.net.\r\nredhat.com.             132     IN      NS      ns1.redhat.com.\r\nredhat.com.             132     IN      NS      ns4.redhat.com.\r\nredhat.com.             132     IN      NS      ns3.redhat.com.\r\nredhat.com.             132     IN      NS      ns2.redhat.com.<\/pre>\n<h4>10. Create .digrc file<\/h4>\n<p>Create\u00a0<strong>.digrc<\/strong>\u00a0file under\u00a0<strong>$HOME\/.digrc<\/strong>\u00a0to store default dig options.<\/p>\n<pre><strong># dig yahoo.com<\/strong>\r\nyahoo.com.              3427    IN      A       72.30.38.140\r\nyahoo.com.              3427    IN      A       98.138.253.109\r\nyahoo.com.              3427    IN      A       98.139.183.24<\/pre>\n<p>We have store\u00a0<strong>+noall<\/strong>\u00a0<strong>+answer<\/strong>\u00a0options permanently in\u00a0<strong>.digrc<\/strong>\u00a0file under user\u2019s home directory. Now, whenever dig command execute it will show only answer section of dig output. No Need to type every-time options like\u00a0<strong>+noall<\/strong><strong>+answer<\/strong>.<\/p>\n<p>In this article, we tried to find out dig command which may help you to search (DNS) Domain Name Service related information. Share your thoughts through comment box.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/10-linux-dig-domain-information-groper-commands-to-query-dns\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our last article we have showed you the most used\u00a08 Nslookup commands\u00a0with their examples, now here we come with another command line tool called\u00a0Dig, which is much similar to Linux\u00a0Nslookup\u00a0tool. We will see the usage of dig command closely with their examples as shown below. Linux Dig Command Examples Dig\u00a0stands for (Domain Information Groper) &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/10-linux-dig-domain-information-groper-commands-to-query-dns\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;10 Linux Dig (Domain Information Groper) Commands to Query DNS&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12601","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12601"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12601\/revisions"}],"predecessor-version":[{"id":12602,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12601\/revisions\/12602"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}