Skip to content

Instantly share code, notes, and snippets.

@bwangelme
Created April 19, 2018 07:02
Show Gist options
  • Save bwangelme/ccf7f35d6e513bbff94e281633fcc3b6 to your computer and use it in GitHub Desktop.
Save bwangelme/ccf7f35d6e513bbff94e281633fcc3b6 to your computer and use it in GitHub Desktop.
Python DNS 查询时指定DNS服务器
#!/usr/bin/env python3
# -*- coding: utf-8 -*-"
import dns.resolver
myResolver = dns.resolver.Resolver()
myResolver.nameservers = ['223.5.5.5', '223.6.6.6']
myAnswers = myResolver.query("www.baidu.com", "A")
for rdata in myAnswers:
print(rdata)
@llxiaoyuan
Copy link

pip install dnspython

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment