domain = input(‘Please input an domain: ‘)
A = dns.resolver.query(domain, ‘A‘) #指定查询类型 A 表示主机记录
for i in A.response.answer: #遍历相应的信息
for j in i.items:
print(j)
MX = dns.resolver.query(domain, ‘MX‘) #指定为邮件交换记录 139.com/163.com
for i in MX:
print(i)
ns = dns.resolver.query(domain,‘NS‘) #标记域名服务器 google.com一级域名
for i in ns.response.answer:
for j in i.items:
print(j)
cname = dns.resolver.query(domain, ‘CNAME‘) #别名
for i in cname.response.answer:
for j in i.items:
print(j)
原文:http://blog.51cto.com/xiaoshanzi/2119043