{"id":825,"date":"2009-11-30T23:48:37","date_gmt":"2009-12-01T04:48:37","guid":{"rendered":"http:\/\/g33kinfo.com\/info\/?p=825"},"modified":"2009-11-30T23:48:37","modified_gmt":"2009-12-01T04:48:37","slug":"dig","status":"publish","type":"post","link":"https:\/\/g33kinfo.com\/info\/dig\/","title":{"rendered":"Dig"},"content":{"rendered":"<p>How to use the dig command<\/p>\n<p>dig is a command-line tool for querying DNS name servers for information about host addresses, mail exchanges, name servers, and related information.<\/p>\n<p>Understanding the default output<\/p>\n<p>The most typical, simplest query is for a single host. By default, however, dig is pretty verbose. You probably don\u2019t need all the information in the default output, but it\u2019s probably worth knowing what it is. Below is an annotated query.<\/p>\n<p>$ dig www.isc.org<\/p>\n<p>That\u2019s the command-line invocation of dig I used.<\/p>\n<p>; < <>> DiG 9.2.3 < <>> www.isc.org<br \/>\n;; global options:  printcmd<\/p>\n<p>The opening section of dig\u2019s output tells us a little about itself (version 9.2.3) and the global options that are set (in this case, printcmd). This part of the output can be quelled by using the +nocmd option, but only if it\u2019s the very first argument on the command line (even preceeding the host you\u2019re querying).<\/p>\n<p>;; Got answer:<br \/>\n;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43071\n;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3\n\nHere, dig tells us some technical details about the answer received from the DNS server. This section of the output can be toggled using the +[no]comments option\u2014but beware that disabling the comments also turns off many section headers.\n\n;; QUESTION SECTION:\n;www.isc.org.                   IN      A\n\nIn the question section, dig reminds us of our query. The default query is for an Internet address (A). You can turn this output on or off using the +[no]question option.\n\n;; ANSWER SECTION:\nwww.isc.org.            600     IN      A       204.152.184.88\n\nFinally, we get our answer: the address of www.isc.org is 204.152.184.88. I don\u2019t know why you\u2019d ever want to turn off the answer, but you can toggle this section of the output using the +[no]answer option.\n\n;; AUTHORITY SECTION:\nisc.org.                2351    IN      NS      ns-int.isc.org.\nisc.org.                2351    IN      NS      ns1.gnac.com.\nisc.org.                2351    IN      NS      ns-ext.isc.org.\n\nThe authority section tells us what DNS servers can provide an authoritative answer to our query. In this example, isc.org has three name servers. You can toggle this section of the output using the +[no]authority option.\n\n;; ADDITIONAL SECTION:\nns1.gnac.com.           171551  IN      A       209.182.216.75\nns-int.isc.org.         2351    IN      A       204.152.184.65\nns-int.isc.org.         2351    IN      AAAA    2001:4f8:0:2::15\n\nThe additional section typically includes the IP addresses of the DNS servers listed in the authority section. This section of the output can be toggled with the +[no]additional option.\n\n;; Query time: 2046 msec\n;; SERVER: 127.0.0.1#53(127.0.0.1)\n;; WHEN: Fri Aug 27 08:22:26 2004\n;; MSG SIZE  rcvd: 173\n\nThe final section of the default output contains statistics about the query; it can be toggled with the +[no]stats option.\n\nWhat can I discover?\n\ndig will let you perform any valid DNS query, the most common of which are A (the IP address), TXT (text annotations), MX (mail exchanges), NS name servers, or the omnibus ANY.\n\n# get the address(es) for yahoo.com\ndig yahoo.com A +noall +answer\n\n# get a list of yahoo's mail servers\ndig yahoo.com MX +noall +answer\n\n# get a list of DNS servers authoritative for yahoo.com\ndig yahoo.com NS +noall +answer\n\n# get all of the above\ndig yahoo.com ANY +noall +answer\n\nMore obscurely, for the present anyway, you can also poll for a host\u2019s IPv6 address using the AAAA option.\n\ndig www.isc.org AAAA +short\n\nIf the domain you want to query allows DNS transfers, you can get those, too. The reality of life on the Internet, however, is that very few domains allow unrestricted transfers these days.\n\ndig yourdomain.com AXFR\n\nHow to a short answer?\n\nWhen all you want is a quick answer, the +short option is your friend:\n\n$ dig www.isc.org +short\n204.152.184.88\n\nnot-quite-so-short answer?\n\nNote that a short answer is different from only an answer. The way to get a detailed answer, but without any auxiliary information, is to turn off all the results (+noall) and then turn on only those sections you want.\n\nHere\u2019s a short answer followed by only an answer; the latter includes all the configuration information, including time-to-live (TTL) data, displayed in a format compatible with BIND configuration files.\n\n$ dig fsf.org mx +short\n20 mx20.gnu.org.\n30 mx30.gnu.org.\n10 mx10.gnu.org.\n\n$ dig +nocmd fsf.org mx +noall +answer\nfsf.org.                3583    IN      MX      30 mx30.gnu.org.\nfsf.org.                3583    IN      MX      10 mx10.gnu.org.\nfsf.org.                3583    IN      MX      20 mx20.gnu.org.\n\nGet a long answer?\n\nAccording to its man page, the +multiline option will give you an answer with \u201cthe SOA records in a verbose multi-line format with human-readable comments.\u201d In general, the answers retrieved using the +multiline option will appear more like BIND config files than they will without it.\n\n$ dig +nocmd ogi.edu any +multiline +noall +answer\nogi.edu.   14267 IN A 129.95.59.31\nogi.edu.   14267 IN MX 5 cse.ogi.edu.\nogi.edu.   14267 IN MX 15 hermes.admin.ogi.edu.\nogi.edu.   14267 IN SOA zeal.admin.ogi.edu. hostmaster.admin.ogi.edu. (\n                   200408230  ; serial\n                   14400      ; refresh (4 hours)\n                   900        ; retry (15 minutes)\n                   3600000    ; expire (5 weeks 6 days 16 hours)\n                   14400      ; minimum (4 hours)\n                   )\nogi.edu.   14267 IN NS zeal.admin.ogi.edu.\nogi.edu.   14267 IN NS cse.ogi.edu.\nogi.edu.   14267 IN NS fork.admin.ogi.edu.\n\nDo a reverse lookup?\n\nUse the -x option to lookup the main hostname associated with an IP address.\n\n$ dig -x 204.152.184.167 +short\nmx-1.isc.org.\n\nIn a loop, this is a slick way to map the names in a given subnet:\n\n#!\/bin\/bash\nNET=18.7.22\nfor n in $(seq 1 254); do\n  ADDR=${NET}.${n}\n  echo -e \"${ADDR}\\t$(dig -x ${ADDR} +short)\"\ndone\n\nQuery a different nameserver?\n\nJust specify it on the command line:\n\ndig @ns1.google.com www.google.com\n\nUse the search list in \/etc\/resolv.conf?\n\nThe host utility will automatically use the search list in your \/etc\/resolv.conf file.\n\n$ host www\nwww.madboa.com has address 65.102.49.170\n\nBy default, however, dig doesn\u2019t\u2014which may produce some unexpected results. If you want to use local hostnames instead of fully qualified domain names, use the +search option.\n\ndig www +search\n\nDo bulk lookups?\n\nIf you want to look up a large number of hostnames, you can put them in a file (one name per line) and use the -f option to query each one in turn.\n\n# do full lookups for a number of hostnames\ndig -f \/path\/to\/host-list.txt\n\n# the same, with more focused output\ndig -f \/path\/to\/host-list.txt +noall +answer\n\nAs far as I can tell, dig versions up to and including 9.2.3 are unable to do reverse lookups using the -f option.\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to use the dig command dig is a command-line tool for querying DNS name servers for information about host addresses, mail exchanges, name servers, and related information. Understanding the default output The most typical, simplest query is for a single host. By default, however, dig is pretty verbose. You probably don\u2019t need all the&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/g33kinfo.com\/info\/dig\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-825","post","type-post","status-publish","format-standard","hentry","category-info"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Dig - Linux Shtuff<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/g33kinfo.com\/info\/dig\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Dig - Linux Shtuff\" \/>\n<meta property=\"og:description\" content=\"How to use the dig command dig is a command-line tool for querying DNS name servers for information about host addresses, mail exchanges, name servers, and related information. Understanding the default output The most typical, simplest query is for a single host. By default, however, dig is pretty verbose. You probably don\u2019t need all the... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/g33kinfo.com\/info\/dig\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Shtuff\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:author\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:published_time\" content=\"2009-12-01T04:48:37+00:00\" \/>\n<meta name=\"author\" content=\"g33kadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/drsinger1111\" \/>\n<meta name=\"twitter:site\" content=\"@drsinger1111\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dig\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dig\\\/\"},\"author\":{\"name\":\"g33kadmin\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"headline\":\"Dig\",\"datePublished\":\"2009-12-01T04:48:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dig\\\/\"},\"wordCount\":158,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"articleSection\":[\"General Info\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dig\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dig\\\/\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dig\\\/\",\"name\":\"Dig - Linux Shtuff\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\"},\"datePublished\":\"2009-12-01T04:48:37+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dig\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dig\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/dig\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Dig\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\",\"name\":\"Linux Shtuff\",\"description\":\"Because I have CRS Syndrome...\",\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\",\"name\":\"g33kadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"contentUrl\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"width\":512,\"height\":512,\"caption\":\"g33kadmin\"},\"logo\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\"},\"description\":\"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\\\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....\",\"sameAs\":[\"https:\\\/\\\/thelinuxreport.com\",\"https:\\\/\\\/fb.me\\\/g33kinf0\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/drsinger1111\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Dig - Linux Shtuff","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/g33kinfo.com\/info\/dig\/","og_locale":"en_US","og_type":"article","og_title":"Dig - Linux Shtuff","og_description":"How to use the dig command dig is a command-line tool for querying DNS name servers for information about host addresses, mail exchanges, name servers, and related information. Understanding the default output The most typical, simplest query is for a single host. By default, however, dig is pretty verbose. You probably don\u2019t need all the... Read More","og_url":"https:\/\/g33kinfo.com\/info\/dig\/","og_site_name":"Linux Shtuff","article_publisher":"https:\/\/fb.me\/g33kinf0","article_author":"https:\/\/fb.me\/g33kinf0","article_published_time":"2009-12-01T04:48:37+00:00","author":"g33kadmin","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/drsinger1111","twitter_site":"@drsinger1111","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/g33kinfo.com\/info\/dig\/#article","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/dig\/"},"author":{"name":"g33kadmin","@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"headline":"Dig","datePublished":"2009-12-01T04:48:37+00:00","mainEntityOfPage":{"@id":"https:\/\/g33kinfo.com\/info\/dig\/"},"wordCount":158,"commentCount":0,"publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"articleSection":["General Info"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/g33kinfo.com\/info\/dig\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/g33kinfo.com\/info\/dig\/","url":"https:\/\/g33kinfo.com\/info\/dig\/","name":"Dig - Linux Shtuff","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/#website"},"datePublished":"2009-12-01T04:48:37+00:00","breadcrumb":{"@id":"https:\/\/g33kinfo.com\/info\/dig\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/g33kinfo.com\/info\/dig\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/g33kinfo.com\/info\/dig\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/g33kinfo.com\/info\/"},{"@type":"ListItem","position":2,"name":"Dig"}]},{"@type":"WebSite","@id":"https:\/\/g33kinfo.com\/info\/#website","url":"https:\/\/g33kinfo.com\/info\/","name":"Linux Shtuff","description":"Because I have CRS Syndrome...","publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/g33kinfo.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547","name":"g33kadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","url":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","contentUrl":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","width":512,"height":512,"caption":"g33kadmin"},"logo":{"@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif"},"description":"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....","sameAs":["https:\/\/thelinuxreport.com","https:\/\/fb.me\/g33kinf0","https:\/\/x.com\/https:\/\/twitter.com\/drsinger1111"]}]}},"_links":{"self":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/825","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/comments?post=825"}],"version-history":[{"count":0,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/825\/revisions"}],"wp:attachment":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/media?parent=825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/categories?post=825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/tags?post=825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}