Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metebalci/0348c514901b8d465140fd491373d988 to your computer and use it in GitHub Desktop.
Save metebalci/0348c514901b8d465140fd491373d988 to your computer and use it in GitHub Desktop.
import dns
import dns.message
import dns.name
import dns.query
import dns.rdatatype
ns = "8.8.8.8"
q = dns.message.make_query(
dns.name.from_text("www.metebalci.com"),
dns.rdatatype.A)
# enable EDNS and set DO bit
q.want_dnssec()
ans = dns.query.udp(q, ns)
for rrset in ans.answer:
for rr in rrset:
# lets print also the qtype of each rr
print('%s %s' % (
dns.rdatatype.to_text(rrset.rdtype),
rr.to_text()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment