+ -
当前位置:首页 → 问答吧 → python通过域名解析双线ip

python通过域名解析双线ip

时间:2011-08-02

来源:互联网

这样的,我有一个服务器,双线的,网通,电信都有ip,我想请问下,如果用python通过域名和其他一些必要的信息,逐个解析出此域名在网通和电信的ip呢?

作者: nothingsss   发布时间: 2011-08-02

这样的功能通过dig可以实现,
直接通过python不能吗?

wt_cmd='dig +retry=%d +time=%d -b %s @%s %s|find /V ";"|find "%s"' %(obj.wt_dns_retry,obj.wt_dns_timeout,obj.wt_int,obj.wt_dns,domain,domain_str)

dx_cmd='dig +retry=%d +time=%d -b %s @%s %s|find /V ";"|find "%s"' %(obj.dx_dns_retry,obj.dx_dns_timeout,obj.dx_int,obj.dx_dns,domain,domain_str)

wt=[re.search('\d+\.\d+\.\d+\.\d+',wtline) for wtline in os.popen(wt_cmd)]
dx=[re.search('\d+\.\d+\.\d+\.\d+',dxline) for dxline in os.popen(dx_cmd)]

希望大仙儿们指点迷津啊

作者: nothingsss   发布时间: 2011-08-02