Reputation: 21261
Here is my simple code:
print host
for rdata in dns.resolver.query(host, 'CNAME') :
prod_host = str(rdata.target)
I'm pulling host
out of a file. When I run this, I get the following:
"www.maizena.es"
Traceback (most recent call last):
File "lexparse.py", line 488, in <module>
dfs(rules_tree)
File "lexparse.py", line 486, in dfs
dfs(child)
File "lexparse.py", line 486, in dfs
dfs(child)
File "lexparse.py", line 471, in dfs
for rdata in dns.resolver.query(host, 'CNAME') :
File "build/bdist.macosx-10.11-intel/egg/dns/resolver.py", line 1132, in query
File "build/bdist.macosx-10.11-intel/egg/dns/resolver.py", line 1051, in query
dns.resolver.NXDOMAIN: None of DNS query names exist: \"www.maizena.es\"., \"www.maizena.es\".masked.domain.com., \"www.maizena.es\".domain.com., \"www.maizena.es\".netarch.domain.com., \"www.maizena.es\".fr.adsvc., \"www.maizena.es\".domainlab.com.
What's odd is that when I run a test in the python repl it seems to work as expected:
bos-mpqpu:config_parse rabdelaz$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dns.resolver
>>> for rdata in dns.resolver.query("www.maizena.es", 'CNAME') :
... prod_host = str(rdata.target)
...
>>> prod_host
'sana.kona.unilever.com.edgekey.net.'
Furthermore, the dns resolution from my command line works just fine:
$ dig www.maizena.es
; <<>> DiG 9.8.3-P1 <<>> www.maizena.es
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15148
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.maizena.es. IN A
;; ANSWER SECTION:
www.maizena.es. 138 IN CNAME sana.kona.unilever.com.edgekey.net.
sana.kona.unilever.com.edgekey.net. 154 IN CNAME e10923.x.akamaiedge.net.
e10923.x.akamaiedge.net. 20 IN A 96.6.167.93
;; Query time: 73 msec
;; SERVER: 172.27.112.15#53(172.27.112.15)
;; WHEN: Tue Jul 25 11:24:11 2017
;; MSG SIZE rcvd: 130
Any insight appreciated.
Upvotes: 2
Views: 11389
Reputation: 45
I got the same error and since this was the first result in google, I wanted to share my solution with you:
If the last char of the domain is a slash (e.g. example.com/) this results in the error "The DNS query name does not exist". After removing the slash, it works as expected.
if(domain[-1] == "/"):
domain = domain[:-1]
Upvotes: 2
Reputation: 2570
I faced the same issue dns.resolver.NXDOMAIN: None of DNS query names exist:
but it was not related to the redundant double quotes.
Because this question is first answer from the search engine for that kind of error, I hope my answer will be helpful for the people who faced the same issue as mine.
You can try to use your current default DNS Server to query the DNS records. It's fixed the issue for me.
Open cmd.exe and run commands below:
ipconfig /all | findstr /R "DNS\ Servers"
C:\>ipconfig /all | findstr /R "DNS\ Servers"
DNS Servers . . . . . . . . . . . : 223.121.180.100
DNS Servers . . . . . . . . . . . : 223.121.180.101
Take first DNS Server IP address and set it as a nameserver for the resolver, as an additional nameservers you can set one from Google and one from Cloudflare.
my_resolver = dns.resolver.Resolver(configure=False)
my_resolver.nameservers = ['223.121.180.100', '8.8.8.8', '1.1.1.1']
answer = my_resolver.query('google.com', 'A')
Upvotes: 2
Reputation: 21261
Issue here is the string actually has double quotes embedded in it. I need to strip those out.
Notice: \"www.maizena.es\"
in the error message.
I modified my script like this:
print repr(host)
for rdata in dns.resolver.query(host[1:-1], 'CNAME') :
prod_host = str(rdata.target)
using print repr()
helped identify the extraneous double quotes.
Upvotes: 2