{"id":871,"date":"2012-01-23T01:10:11","date_gmt":"2012-01-23T06:10:11","guid":{"rendered":"http:\/\/yourLinuxGuy.com\/?p=871"},"modified":"2012-01-23T21:21:41","modified_gmt":"2012-01-24T02:21:41","slug":"bash-ping-test-for-domain-controllers","status":"publish","type":"post","link":"https:\/\/yourLinuxGuy.com\/?p=871","title":{"rendered":"Bash Ping Test for Domain Controllers"},"content":{"rendered":"<p>DNS can be a funny and unpredictable beast.<\/p>\n<p>It is paramount that the DNS environment be stable and standardized in large environments, as well as small.\u00a0 But in large environments particularly, you run into some weird happenings&#8230;\u00a0 Like for instance, where an Active Directory exists separately from the DNS environment, the DNS world can sometimes get out of sync without all the AD controls.<\/p>\n<p>So if you have an environment where you cannot be certain that all the &#8220;A&#8221; records for your parent domain are properly registered and represented, you might want to regularly check up on the domain&#8217;s records with a script.\u00a0 I&#8217;ve tossed together a fairly simple script that prompts you for the parent domain name, an IP address of a reliable DNS server, and then it goes out and makes sure that all the hosts listed as &#8220;A&#8221; records for the parent domain are actually *up* and responding to ping&#8230;<\/p>\n<p>Just copy\/paste the following into a file, and <code>chmod +x<\/code> the file, and then run it.\u00a0 Enjoy!<\/p>\n<pre dir=\"ltr\">#!\/bin\/bash\r\n\r\necho \"What is the domain name to check? (like example.com): \"\r\nread DOMNAME\r\necho \"\"\r\necho \"What is an authoritative DNS server for that domain? (like 10.1.2.3): \"\r\nread AUTHDNS\r\n\r\nfor item in `nslookup $DOMNAME - $AUTHDNS| grep \"Address:\"| awk '{ print $2 }'|grep -v \"#53\"`; do echo \"Checking $item... \";ping -q -c 2 $item &gt; \/tmp\/lastitem.txt; temp=\"$?\";if [ \"$temp\" == \"1\" ]; then echo $item is unreachable;fi; done\r\n\r\necho \"...Done!\"<\/pre>\n<p>I hope that helps someone out there&#8230;<br \/>\n\ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>DNS can be a funny and unpredictable beast. It is paramount that the DNS environment be stable and standardized in large environments, as well as small.\u00a0 But in large environments particularly, you run into some weird happenings&#8230;\u00a0 Like for instance,&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/yourLinuxGuy.com\/?p=871\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11,47,1],"tags":[],"class_list":["post-871","post","type-post","status-publish","format-standard","hentry","category-intermediate","category-linuxgeneral","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnjn1-e3","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=871"}],"version-history":[{"count":7,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/871\/revisions"}],"predecessor-version":[{"id":898,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/871\/revisions\/898"}],"wp:attachment":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}