{"id":237,"date":"2012-03-06T16:22:48","date_gmt":"2012-03-06T08:22:48","guid":{"rendered":"http:\/\/play.datalude.com\/blog\/?p=237"},"modified":"2012-03-06T16:59:53","modified_gmt":"2012-03-06T08:59:53","slug":"summarizing-dig-info-with-a-bash-script","status":"publish","type":"post","link":"https:\/\/play.datalude.com\/blog\/2012\/03\/summarizing-dig-info-with-a-bash-script\/","title":{"rendered":"Summarizing dig Info with a bash script."},"content":{"rendered":"<p>Dig is a great tool, but most of its output is not very interesting. There are a bunch of command line options that I can never remember without a quick 'man dig' which always sounds a bit odd. So I whipped up a quick script. It takes a domain name as the argument, and then pumps out the Reverse IP lookup, Nameservers, and Mail servers with reverse lookup of their IPs.<\/p>\n<pre>#!\/bin\/bash<\/pre>\n<pre>QUERYDOMAIN=$1<\/pre>\n<pre>echo \"Reverse IP:\"\r\n echo \"\u00a0\u00a0\u00a0 \" `dig x +short $QUERYDOMAIN`\r\n echo \"Nameservers\"\r\n NAMESERVERS=`dig ns +short $QUERYDOMAIN | sed \"s\/^[0-9]* \/\/g\"`\r\n for SERVER in $NAMESERVERS;\r\n do\r\n echo \"\u00a0\u00a0\u00a0 \" $SERVER \" = \" `dig x +short $SERVER`;\r\n done\r\n echo \"Mail Servers:\"\r\n MAILSERVERS=`dig mx +short $QUERYDOMAIN | sed \"s\/^[0-9]* \/\/g\"`\r\n for SERVER in $MAILSERVERS;\r\n do\r\n echo \"\u00a0\u00a0\u00a0 \" $SERVER \" = \" `dig x +short $SERVER`;\r\n done<\/pre>\n<p>The output looks like this:<\/p>\n<p><!--more-->scripts\/diggety.sh hp.com<br \/>\nReverse IP:<br \/>\n15.216.110.22 15.216.110.139 15.216.110.140 15.192.45.21 15.192.45.22 15.192.45.138 15.192.45.139 15.216.110.21 15.240.238.51 15.240.238.55 15.193.112.21 15.193.112.23 15.201.49.21<br \/>\nNameservers<br \/>\nns1.hp.com.\u00a0 =\u00a0 15.219.145.12<br \/>\nns2.hp.com.\u00a0 =\u00a0 15.219.160.12<br \/>\nns3.hp.com.\u00a0 =\u00a0 15.203.209.12<br \/>\nns5.hp.com.\u00a0 =\u00a0 15.195.192.37<br \/>\nns6.hp.com.\u00a0 =\u00a0 15.195.208.12<br \/>\nMail Servers:<br \/>\nsmtp.hp.com.\u00a0 =\u00a0 15.193.32.72<\/p>\n<p>I spent about 20 minutes writing the script, and then it just saved me about 30 minutes work when a client called, wanting to troubleshoot their mail servers over 20 domains. That's what bash scripts are all about &#8230; hope it saves you some time too.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dig is a great tool, but most of its output is not very interesting. There are a bunch of command line options that I can never remember without a quick 'man dig' which always sounds a bit odd. So I whipped up a quick script. It takes a domain name as the argument, and then &#8230; <a title=\"Summarizing dig Info with a bash script.\" class=\"read-more\" href=\"https:\/\/play.datalude.com\/blog\/2012\/03\/summarizing-dig-info-with-a-bash-script\/\" aria-label=\"Read more about Summarizing dig Info with a bash script.\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1,4],"tags":[],"class_list":["post-237","post","type-post","status-publish","format-standard","hentry","category-it","category-linux"],"_links":{"self":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts\/237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/comments?post=237"}],"version-history":[{"count":0,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts\/237\/revisions"}],"wp:attachment":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/media?parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/categories?post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/tags?post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}