有没有办法指定dns服务器应该由socket.gethostbyaddr()使用?
答案 0 :(得分:4)
请纠正我,如果我错了,但这不是操作系统的责任吗? 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,因为它是系统配置的一部分。
答案 1 :(得分:2)
看看PyDNS
。