dnspython实现CNAME记录查询

[root@bogon dns]# vim CNAME.py

!/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()

测试:

[root@bogon dns]# python CNAME.py
Please input an domain: www.baidu.com
www.a.shifen.com.
[root@bogon dns]#

你可能感兴趣的:(dnspython实现CNAME记录查询)