-
#when trying to run this code #!/usr/bin/python def resolvOrDie(host,timeout=4): #Finding A record #resolver = dns.resolver.Resolver('/etc/resolv.conf',configure=True) # reads /etc/resolv by default, no need print(f"this is search path {resolver.search}") #resolver.use_search_by_default = False I get this output: this is search path [, , , , , , ] and I use nslookup $ nslookup hits | grep -A 2 Name nslookup knows to use my dns search path and resolves. How can I make python do the same thing? I can't seem to figure out how to make dnspython use my search path. What am I missing? Please let me know if you need any more information |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The problem is this line in
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:
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
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 pass a string as the query name, and don't end it with a ".".
|
Beta Was this translation helpful? Give feedback.
The problem is this line in
resolvOrDie()
: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:
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
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…