try: import dns.resolver except: print "you need to install dnspython : sudo easy_install dnspython" raise import commands def dnstest(hostname, name, dnsip): print "testing : " + name + " ( " + dnsip + " ) " res = dns.resolver.Resolver(configure=False) res.nameservers = [dnsip] ip = res.query(hostname)[0].address print ip ping = commands.getstatusoutput("ping -c 5 -q " + ip)[1] print ping print "----------------------------------" def test(hostname): print "====== testing : " + hostname + " ===========" nameservers = [{'ip': '8.8.8.8', 'name':'Google'}, {'ip': '208.67.222.222', 'name':'OpenDNS'}] dnstest(hostname, "default", str(dns.resolver.Resolver().nameservers[0])) for nameserver in nameservers: dnstest(hostname, nameserver['name'], nameserver['ip']) print "=====================================" test('cdn.thaindian.com') #internap/softlayer test('profile.ak.fbcdn.net') #Akamai test('cdn.twitbooth.com') #Cloudfront test('ticdn.thaindian.netdna-cdn.com') #MaxCDN