Question

Im working on project where i need to test if domains has IPv6 addresses in MX, AAAA records. Id like to use Python for script coding. I find out about dnsPython and installed it but it seems not working at all.

when I execute this simple code:

import dns.resolver

answers = dns.resolver.query('dnspython.org', 'MX')
for rdata in answers:
    print 'Host', rdata.exchange, 'has preference', rdata.preference

I get this error:

Traceback (most recent call last):
  File "H:\Python_workspace\Test\Zdroj\bbb.py", line 9, in <module>
    answers = dns.resolver.query('dnspython.org', 'MX')
  File "build\bdist.win32\egg\dns\resolver.py", line 920, in query
  File "build\bdist.win32\egg\dns\resolver.py", line 847, in query
  File "build\bdist.win32\egg\dns\resolver.py", line 692, in _compute_timeout
dns.exception.Timeout

I used to code in Java, but there if was some error during compilation I was able to find out what was wrong thanks to error description, but here im lost, I cant find anything useful from error that i could use to find the mistake. It looks like something is missing, or badly installed libraries.

Was it helpful?

Solution

The exception you are getting is: dns.exception.Timeout. This is not a compile error, but a runtime exception. This is probably due to your firewall or router settings disallowing dnspython from making the DNS queries it needs to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top