Questions tagged [dnspython]

DNSPython is a Python package that provides high and low level access to DNS.

DNSPython is a Python package that provides high and low level access to DNS. Find more information here: http://www.dnspython.org/

116 questions
19
votes
3 answers

How do we get TXT, CNAME and SOA records from dnspython?

I have a requirement to have a dns query function to query a server for various records. I figured out how to get the MX record (most of the examples show this), A record and NS record. How do I get the TXT, CNAME and SOA records? Sample code…
Shabareesh
  • 331
  • 1
  • 2
  • 7
17
votes
3 answers

Tell urllib2 to use custom DNS

I'd like to tell urllib2.urlopen (or a custom opener) to use 127.0.0.1 (or ::1) to resolve addresses. I wouldn't change my /etc/resolv.conf, however. One possible solution is to use a tool like dnspython to query addresses and httplib to build a…
Attila O.
  • 15,659
  • 11
  • 54
  • 84
13
votes
1 answer

Dnspython: Setting query timeout/lifetime

I have a small script that checks a large list of domains for their MX records, everything works fine but when the script finds a domain with no record, it takes quite a long time to skip to the next one. I have tried adding: query.lifetime =…
Christopher Long
  • 854
  • 4
  • 11
  • 21
13
votes
5 answers

How can I find the authoritative DNS server for a domain using dnspython?

As part of a tool I'm writing I want to have a diagnostic that will tell the user whether they have configured their domain's DNS correctly for a particular service. I want to query the authoritative DNS server for their domain so that I can bypass…
Jon Colverson
  • 2,986
  • 1
  • 24
  • 24
11
votes
1 answer

How make dns queries in dns-python as dig (with additional records section)?

I trying use dns python and want get all records with ANY type query: import dns.name import dns.message import dns.query domain = 'google.com' name_server = '8.8.8.8' domain = dns.name.from_text(domain) if not domain.is_absolute(): domain =…
tbicr
  • 24,790
  • 12
  • 81
  • 106
10
votes
2 answers

Is it reasonable in Python to check for a specific type of exception using isinstance?

Is it reasonable in Python to catch a generic exception, then use isinstance() to detect the specific type of exception in order to handle it appropriately? I'm playing around with the dnspython toolkit at the moment, which has a range of exceptions…
Vortura
  • 1,315
  • 15
  • 15
10
votes
2 answers

Eventlet + DNS Python Attribute Error: module "dns.rdtypes" has no attribute ANY

I know that someone will face this problem. I had this problem today, but I could fix it promptly, and I want to share my solution: Problem: from flask_socketio import SocketIO You will receive an output error with something like: Attribute Error:…
9
votes
1 answer

dnspython3 remove host from A record

Consider this scenario: With nsupdate I'm able to remove IP from a A record using following method: update delete test-record.mydomain.com 60 A 172.16.1.4 This is my naive implementation with dnspython, where bind_host is our bind server,…
mobu
  • 547
  • 3
  • 6
  • 11
6
votes
2 answers

returning 'A' DNS record in dnspython

I am using dnspython to get the 'A' record and return the result (IP address for a given domain). I have this simple testing python script: import dns.resolver def resolveDNS(): domain = "google.com" resolver = dns.resolver.Resolver(); …
None
  • 281
  • 1
  • 6
  • 16
6
votes
1 answer

dnspython - get AAAA, A, NS and other records with one query

I'm trying to build fast script for parsing all DNS records for a single domain name. The 'ANY' command seems to do the trick, but I have strange problems with TTLs. When using ANY like this domain = dns.name.from_text(domain) nameserver =…
nacholibre
  • 3,874
  • 3
  • 32
  • 35
5
votes
2 answers

ModuleNotFoundError: No module named 'dnspython'

I am trying to import the module dnspython in a python 3.6 script using import dnspython. pip3 freeze shows that the package is installed but I keep getting the error ModuleNotFoundError: No module named 'dnspython' I have tried: pip3 install…
Charalamm
  • 1,547
  • 1
  • 11
  • 27
5
votes
1 answer

Python DNS resolver and original TTL

I need to get original TTL for dns record on each query. DNS resolver shows original ttl only at first query. It shows time to reset cache on each next query. >>> answer = dns.resolver.query('www.stackoverflow.com') >>> print…
Alex Zaitsev
  • 690
  • 6
  • 17
4
votes
3 answers

How to configure mypy to ignore a stub file for a specific module?

I installed a "dnspython" package with "pip install dnspython" under Ubuntu 22.10 and made a following short script: #!/usr/bin/env python3 import dns.zone import dns.query zone = dns.zone.Zone("example.net") dns.query.inbound_xfr("10.0.0.1",…
Martin
  • 957
  • 7
  • 25
  • 38
4
votes
0 answers

Detecting orphaned subdomain using dnspython

I am trying to figure out how I can utilize dnspython to detect orphaned subdomains. To explain this problem, let us consider an example scenario: A company DNStest owns the domain example.com Now the blog team and HR team at the company DNStest…
InquisitiveGirl
  • 667
  • 3
  • 12
  • 31
4
votes
2 answers

How can I get the hostname, aliases, ip address, and canonical name of a device (without asking a library to read /etc/hosts) using python?

I want to get these fields about a device given an identifier: hostname, aliases, ip address, & canonical name I can get these by using socket: socket.gethostbyaddr('machine-name') However, every socket call opens the hosts file (/etc/hosts) and…
Jonathan Allen Grant
  • 3,408
  • 6
  • 30
  • 53
1
2 3 4 5 6 7 8