python: 如何指定socket.gethostbyaddr()使用哪个DNS服务器
有没有办法指定 socket.gethostbyaddr() 使用哪个 DNS 服务器?
2 个回答
1
看看这个 PyDNS
。
5
请纠正我,如果我说错了的话,但这不是操作系统的责任吗?gethostbyaddr
只是 libc 的一部分,根据 man
的说明:
The gethostbyname(), gethostbyname2() and gethostbyaddr() functions each return a pointer to an object with the following structure describing an internet host refer- enced by name or by address, respectively. This structure contains either the infor- mation obtained from the name server, named(8), or broken-out fields from a line in /etc/hosts. If the local name server is not running these routines do a lookup in /etc/hosts.
所以我认为从代码的角度来看,没有办法简单地 告诉 Python 使用特定的 DNS,因为这属于系统的配置。