{"id":3591,"date":"2014-03-26T12:01:50","date_gmt":"2014-03-26T17:01:50","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=3591"},"modified":"2014-03-26T12:02:30","modified_gmt":"2014-03-26T17:02:30","slug":"python-dig-query","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2014\/03\/26\/python-dig-query\/","title":{"rendered":"Python dig query"},"content":{"rendered":"<p>Nothing much, just a script to walk the tree for a given name.  It starts at a CNAME and walks its way all the way down to the A record and IP address.  In the context of larger script that attempted to connect to a given URL, we used this to troubleshoot incompatibilities between firewall timeout and DNS timeout settings.<\/p>\n<pre lang=\"python\">\r\n#!\/usr\/bin\/env python\r\n\r\nimport dns.resolver, sys\r\nhostname = sys.argv[1]\r\nprint \"issuing recursive name lookup (simulates dig)...\"\r\nn=hostname\r\ntry:\r\n  while True:\r\n    for rdata in dns.resolver.query(n, 'CNAME') :\r\n      print rdata\r\n      n=rdata.target\r\nexcept:\r\n  for rdata in dns.resolver.query(n) :\r\n    print rdata\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Nothing much, just a script to walk the tree for a given name. It starts at a CNAME and walks its way all the way down to the A record and IP address. In the context of larger script that&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2014\/03\/26\/python-dig-query\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[24,26],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/3591"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=3591"}],"version-history":[{"count":4,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/3591\/revisions"}],"predecessor-version":[{"id":3607,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/3591\/revisions\/3607"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3591"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}