Jon
Jon

Reputation: 332

dnspython does not resolve on osx inside corporate network

I am trying to use dnspython to resolve some names on our corporate network on mac osx. There is the sample code I am using:

import dns.resolver

dns.resolver.default_resolver = dns.resolver.Resolver(configure=False)
dns.resolver.default_resolver.nameservers = ['x.x.x.x']
dns.resolver.resolve('www.google.com')

x.x.x.x is replaced with the corporate dns server. When run, the following error message is generated:

dns.resolver.LifetimeTimeout: The resolution lifetime expired after 5.402 seconds: Server Do53:135.37.9.16@53 answered The DNS operation timed out.

Using dig to make the query, I do get back valid results:

jon@laptop play3 % dig www.google.com

; <<>> DiG 9.10.6 <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17452
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;www.google.com.            IN  A

;; ANSWER SECTION:
www.google.com.     235 IN  A   74.125.21.103
www.google.com.     235 IN  A   74.125.21.106
www.google.com.     235 IN  A   74.125.21.105
www.google.com.     235 IN  A   74.125.21.147
www.google.com.     235 IN  A   74.125.21.104
www.google.com.     235 IN  A   74.125.21.99

;; Query time: 19 msec
;; SERVER: x.x.x.x#53(x.x.x.x)
;; WHEN: Fri Dec 06 09:25:51 EST 2024
;; MSG SIZE  rcvd: 139

In the dig resopsone, I see the same name servers being used to do the lookup. I have tried to adjust the timeout in python, using 8.8.8.8 as the dns server, and many other options including edns, but all changes result with same timeout exception.

Upvotes: 0

Views: 23

Answers (0)

Related Questions