Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python: how to tell socket.gethostbyaddr() which dns server to use

is there any way to specify dns server should be used by socket.gethostbyaddr()?

like image 212
m1k3y3 Avatar asked Feb 22 '11 12:02

m1k3y3


2 Answers

Please correct me, if I'm wrong, but isn't this operating system's responsibility? gethostbyaddr is just a part of libc and according to 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.

So I would say there's no way of simply telling Python (from the code's point of view) to use a particular DNS, since it's part of system's configuration.

like image 109
Michal Chruszcz Avatar answered Oct 06 '22 17:10

Michal Chruszcz


Take a look at PyDNS.

like image 31
NPE Avatar answered Oct 06 '22 17:10

NPE