使用DNS.resolver的DNS应答错误



我正在使用非常有用的pythondns库。不幸的是,我收到了错误的答案。或者我应该说,当我应该有决心的时候,我得到了一个否定的答案。

这是我的代码:

import dns.resolver
my_resolver = dns.resolver.Resolver()
my_resolver.nameservers = ['8.8.8.8']
answer = my_resolver.query('mail1.avem-groupe.com')

答案:

>>> answer = my_resolver.query('mail1.avem-groupe.com', 'MX')
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/dns/resolver.py", line 213, in __init__
rdclass, rdtype)
File "/usr/lib/python3/dist-packages/dns/message.py", line 341, in find_rrset
raise KeyError
KeyError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/dns/resolver.py", line 223, in __init__
dns.rdatatype.CNAME)
File "/usr/lib/python3/dist-packages/dns/message.py", line 341, in find_rrset
raise KeyError
KeyError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/dns/resolver.py", line 1004, in query
raise_on_no_answer)
File "/usr/lib/python3/dist-packages/dns/resolver.py", line 232, in __init__
raise NoAnswer(response=response)
dns.resolver.NoAnswer: The DNS response does not contain an answer to the question: mail1.avem-groupe.com. IN MX

DIG:的结果

$ dig mail1.avem-groupe.com
; <<>> DiG 9.11.16-2-Debian <<>> mail1.avem-groupe.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7544
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;mail1.avem-groupe.com.     IN  A
;; ANSWER SECTION:
mail1.avem-groupe.com.  3575    IN  A   31.172.163.202
;; AUTHORITY SECTION:
avem-groupe.com.    172775  IN  NS  ns-35-b.gandi.net.
avem-groupe.com.    172775  IN  NS  ns-108-c.gandi.net.
avem-groupe.com.    172775  IN  NS  ns-35-a.gandi.net.
;; Query time: 27 msec
;; SERVER: 5.132.191.104#53(5.132.191.104)
;; WHEN: Mon Mar 30 11:17:49 CEST 2020
;; MSG SIZE  rcvd: 142

我以为这是一个名称服务器issue,所以我改为谷歌DNS(按照上面显示的代码(,但结果相同。

知道吗?

好吧,这太愚蠢了。

我只是用dig而不是MX 提出了一个"a"请求

对于"MX"请求,我得到了与pythondns相同的结果

$ dig mail1.avem-groupe.com MX
; <<>> DiG 9.11.16-2-Debian <<>> mail1.avem-groupe.com MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4276
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;mail1.avem-groupe.com.     IN  MX
;; AUTHORITY SECTION:
avem-groupe.com.    10800   IN  SOA ns1.gandi.net. hostmaster.gandi.net. 1580726993 10800 3600 604800 10800
;; Query time: 46 msec
;; SERVER: 5.132.191.104#53(5.132.191.104)
;; WHEN: Mon Mar 30 17:17:47 CEST 2020
;; MSG SIZE  rcvd: 110

相关内容

  • 没有找到相关文章

最新更新