dnspython实现A记录查询

创建文件,保存下面的内容
[root@bogon dns]# vim A.py

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

测试:
[root@bogon dns]# python A.py
Please input an domain: www.nyist.net
222.139.215.198
[root@bogon dns]#

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