Skip to content

I can't get dns resolver not using my search path. #964

Answered by rthalley
hohmann22 asked this question in Q&A
Discussion options

You must be logged in to vote

The problem is this line in resolvOrDie():

host = dns.name.from_text(host)

Dnspython supports both relative and absolute (also known as "fully-qualified") names. By default, dns.name.from_text() will create an absolute name, which you can see is happening in your case looking at your test output:

DNS query for ansible. no record ...

That "." at the end of "ansible." means the name is absolute. Search lists are only applied to relative names. So, one fix is to change that line to

host = dns.name.from_text(host, None)

which will make "www" relative.

But there is a much simpler way to do what you want to do, with searching and a lifetime, and you can even use the default resolver. Just pa…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hohmann22
Comment options

Answer selected by rthalley
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants