Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!zen.net.uk!dedekind.zen.co.uk!reader02.nrc01.news.zen.net.uk.POSTED!not-for-mail From: Nobody Subject: Re: Subprocess puzzle and two questions Date: Thu, 15 Nov 2012 22:54:10 +0000 User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.python References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lines: 23 Organization: Zen Internet NNTP-Posting-Host: 8ad5da6b.news.zen.co.uk X-Trace: DXC=g1OY>KI3UGkD@=;2MRL^Km]G;bfYi23hd=dR0\ckLKG`WeZ<[7LZNRf[^LonJMCiNjNQ<`Sf8^TaoH2mc=WRWA``jMF[@JSMFif X-Complaints-To: abuse@zen.co.uk Xref: csiph.com comp.lang.python:33404 On Wed, 14 Nov 2012 20:49:19 -0500, Roy Smith wrote: >> I'm slightly surprised that there's no way with the Python stdlib to >> point a DNS query at a specific server > > Me too, including the "only slightly" part. The normal high-level C > resolver routines (getaddrinfo/getnameinfo, or even the old > gethostbyname series), don't expose any way to do that. That's because the high-level routines aren't tied to DNS. gethostbyname() and getaddrinfo() use the NSS (name-service switch) mechanism, which is configured via /etc/nsswitch.conf. Depending upon configuration, hostnames can be looked up via a plain text file (/etc/hosts), Berkeley DB files, DNS, NIS, NIS+, LDAP, WINS, etc. DNS is just one particular back-end, which may or may not be used on any given system. If you specifically want to perform DNS queries, you have to use a DNS-specific interface (e.g. the res_* functions described in the resolver(3) manpage), or raw sockets, rather than a high-level interface such as gethostbyname() or getaddrinfo().