python自动化运维笔记(2)—-dnspython
准备工作 环境:Ubuntu 14.04 32bit 工具:dnspython 对应的shell工具:nslookup dig等 dns预备知识: 常用资源记录RR(Resource Records)类型 A记录: 主机名–> IP地址 MX记录: 定义邮件服务器域名 CNAME: 域名间映射 PTR: IP地址 –>主机名(反向解析) 更详细介绍参考博文《 [DNS]常见资源记录定义(Resource Record) 》 用法举例 查询A记录 import dns.resolver domain = raw_input(‘input an domain:’) A = dns.resolver.query(domain, ‘A’) for i in A.response.answer: for j in i.items: if ‘address’ in dir(j): print j.address else: print ‘failed to […]