{"id":8562,"date":"2023-03-14T14:33:12","date_gmt":"2023-03-14T14:33:12","guid":{"rendered":"https:\/\/www.geekdecoder.com\/?p=8562"},"modified":"2023-03-14T14:33:12","modified_gmt":"2023-03-14T14:33:12","slug":"how-to-use-the-dig-command-in-linux","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2023\/03\/14\/how-to-use-the-dig-command-in-linux\/","title":{"rendered":"How to Use the Dig Command in Linux"},"content":{"rendered":"\n<p>The dig command in Linux is used to perform DNS lookups and query DNS servers. Here are some common ways to use dig.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>First, install dig if it is not installed. See &#8211; <a href=\"https:\/\/www.geekdecoder.com\/how-to-install-dig-utility-of-centos\/\">https:\/\/www.geekdecoder.com\/how-to-install-dig-utility-of-centos\/<\/a><\/p>\n\n\n\n<p>To query a specific DNS server for information about a domain name.<\/p>\n\n\n\n<p>For example, to query the Google DNS server (8.8.8.8) for information about geekdecoder.com:<\/p>\n\n\n\n<p>dig @8.8.8.8 geekdecoder.com<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndig @8.8.8.8 geekdecoder.com\n<\/pre><\/div>\n\n\n<p>Output<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n dig @8.8.8.8 geekdecoder.com\n\n; &lt;&lt;&gt;&gt; DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.13 &lt;&lt;&gt;&gt; @8.8.8.8 geekdecoder.com\n; (1 server found)\n;; global options: +cmd\n;; Got answer:\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 13730\n;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 512\n;; QUESTION SECTION:\n;geekdecoder.com.               IN      A\n\n;; ANSWER SECTION:\ngeekdecoder.com.        14400   IN      A       192.99.236.66\n\n;; Query time: 31 msec\n;; SERVER: 8.8.8.8#53(8.8.8.8)\n;; WHEN: Tue Mar 14 14:25:57 UTC 2023\n;; MSG SIZE  rcvd: 60\n\n<\/pre><\/div>\n\n\n<p>To get more detailed information about a domain name.<\/p>\n\n\n\n<p>dig domain-name<br>For example:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndig geekdecoder.com\n<\/pre><\/div>\n\n\n<p>Output<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndig geekdecoder.com\n\n; &lt;&lt;&gt;&gt; DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.13 &lt;&lt;&gt;&gt; geekdecoder.com\n;; global options: +cmd\n;; Got answer:\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 46107\n;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 512\n;; QUESTION SECTION:\n;geekdecoder.com.               IN      A\n\n;; ANSWER SECTION:\ngeekdecoder.com.        14400   IN      A       192.99.236.66\n\n;; Query time: 111 msec\n;; SERVER: 67.207.67.3#53(67.207.67.3)\n;; WHEN: Tue Mar 14 14:29:04 UTC 2023\n;; MSG SIZE  rcvd: 60\n\n<\/pre><\/div>\n\n\n<p><br>To query for a specific record type:<\/p>\n\n\n\n<p>dig record-type domain-name<br>For example, to query for the mail servers (MX records) for geekdecoder.com:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndig MX geekdecoder.com\n<\/pre><\/div>\n\n\n<p>Output<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n dig MX geekdecoder.com\n\n; &lt;&lt;&gt;&gt; DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.13 &lt;&lt;&gt;&gt; MX geekdecoder.com\n;; global options: +cmd\n;; Got answer:\n;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 6621\n;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version: 0, flags:; udp: 512\n;; QUESTION SECTION:\n;geekdecoder.com.               IN      MX\n\n;; ANSWER SECTION:\ngeekdecoder.com.        14400   IN      MX      0 mail.geekdecoder.com.\n\n;; Query time: 101 msec\n;; SERVER: 67.207.67.3#53(67.207.67.3)\n;; WHEN: Tue Mar 14 14:30:37 UTC 2023\n;; MSG SIZE  rcvd: 65\n\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p>You can also combine options to get more specific results, such as:<\/p>\n\n\n\n<p>dig +short A domain.com<br>This will return only the IP addresses (A records) for geekdecoder.com in a concise format.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndig +short A geekdecoder.com\n<\/pre><\/div>\n\n\n<p>Output<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndig +short A geekdecoder.com\n192.99.236.66\n<\/pre><\/div>\n\n\n<p>For more information about the dig command and its options, you can consult the dig manual page by typing man dig in the terminal.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The dig command in Linux is used to perform DNS lookups and query DNS servers. Here are some common ways to use dig.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,27],"tags":[],"class_list":["post-8562","post","type-post","status-publish","format-standard","hentry","category-administration","category-dns"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/8562","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=8562"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/8562\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=8562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=8562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=8562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}