gpt4 book ai didi

python - 为什么我用 dnspython 无法获取权限信息,而 nslookup 很有用

转载 作者:太空宇宙 更新时间:2023-11-03 17:00:57 33 4
gpt4 key购买 nike

#code like this
import dns
import dns.resolver
import dns.name
import dns.message
import dns.query

request = dns.message.make_query("google.com",dns.rdatatype.NS)
response = dns.query.udp(request,"216.239.32.10")
print response.authority

但它是空的

然后当使用“nslookup google.com 216.239.32.10 ”时

可以获得

服务器:216.239.32.10地址:216.239.32.10#53

名称:google.com地址:216.58.221.238显然这是权威答案但是为什么我使用dnspython时无法获取权限部分?

最佳答案

你确定吗?

c:\srv>nslookup google.com 216.239.32.10
Server: ns1.google.com
Address: 216.239.32.10

Name: google.com
Addresses: 2a00:1450:400f:805::200e
178.74.30.16
178.74.30.49
178.74.30.37
178.74.30.24
178.74.30.26
178.74.30.59
178.74.30.57
178.74.30.48
178.74.30.46
178.74.30.27
178.74.30.53
178.74.30.35
178.74.30.20
178.74.30.42
178.74.30.31
178.74.30.38

c:\srv>python
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import dns
>>> import dns.resolver, dns.name
>>> import dns.message, dns.query
>>> r = dns.message.make_query('google.com', dns.rdatatype.NS)
>>> resp = dns.query.udp(r, '216.239.32.10')
>>> print resp.authority
[]
>>> print resp
id 63079
opcode QUERY
rcode NOERROR
flags QR AA RD
;QUESTION
google.com. IN NS
;ANSWER
google.com. 345600 IN NS ns3.google.com.
google.com. 345600 IN NS ns4.google.com.
google.com. 345600 IN NS ns2.google.com.
google.com. 345600 IN NS ns1.google.com.
;AUTHORITY
;ADDITIONAL
ns3.google.com. 345600 IN A 216.239.36.10
ns4.google.com. 345600 IN A 216.239.38.10
ns2.google.com. 345600 IN A 216.239.34.10
ns1.google.com. 345600 IN A 216.239.32.10
>>>

关于python - 为什么我用 dnspython 无法获取权限信息,而 nslookup 很有用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34989032/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com