学习python自动化运维之模块域名解析方法详解

1.MX

    

#!/usr/bin/env python


import dns.resolver


domain = raw_input('please input an domain: ')

MX = dns.resolver.query(domain, 'MX')

for i in MX:

        print 'MX preference =', i.preference, 'mail exchanger =', i.exchange


2.NS

#/usr/bin/env python




import dns.resolver

domain = raw_input('please input an domain: ')

ns = dns.resolver.query(domain, 'NS')

for i in ns.response.answer:

        for j in i.items:

                print j.to_text()


3.A记录

#!/usr/bin/env python


import dns.resolver

domain = raw_input('please input an domain: ')

A = dns.resolver.query(domain, 'A')

for i in A.response.answer:

        for j in i.items:

                print j.address


4.CNAME

#!/usr/bin/env python


import dns.resolver


domain = raw_input('please input an domain: ')

cname = dns.resolver.query(domain, 'CNAME')

for i in cname.response.answer:

        for j in i.items:

                print j.to_text()


你可能感兴趣的:(python,domain,记录,Please)