域名dns检查

先安装dnspython模块,可以指定dns服务器,自动检查各环境的dns解析,进行相关运维检查

pip install  dnspython

import dns

SERVER = "114.114.114.114"   #指定dns查询服务器

PORT = 53 #DNS server port

dns_query = dns.message.make_query("www.baidu.com", "A")

response = dns.query.udp(dns_query, SERVER, port = PORT)

for i in response.answer:

    print(i.to_text())

你可能感兴趣的:(域名dns检查)