python:如何告诉socket.gethostbyaddr()使用哪个dns服务器

时间:2011-02-22 12:51:39

标签: python sockets dns

有没有办法指定dns服务器应该由socket.gethostbyaddr()使用?

2 个答案:

答案 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