1. 程式人生 > >dns記錄

dns記錄

dns

import dns.resolver

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.address)

    print(j)

MX = dns.resolver.query(domain, ‘MX‘) #指定為郵件交換記錄 139.com/163.com
for i in MX:
print(i)

print(‘MX preference =‘, i.preference(‘優先級‘), ‘mail exchanger =‘, i.exchange(‘FQDN名,完整的合格域名‘))

ns = dns.resolver.query(domain,‘NS‘) #標記域名服務器 google.com一級域名
for i in ns.response.answer:
for j in i.items:

print(j.to_text())

    print(j)

cname = dns.resolver.query(domain, ‘CNAME‘) #別名
for i in cname.response.answer:
for j in i.items:
print(j)

dns記錄