On Monday, 30 September 2013 14:54:41 UTC+2, Ervin Hegedüs wrote: > Hello, > > > > On Mon, Sep 30, 2013 at 04:42:29AM -0700, Michel Albert wrote: > > > Hi, > > > > > > ``socket.gethostbyname`` sends the DNS resolution query to the DNS server > > specified by the OS. Is there an easy way to send a query to a *different* > > server? > > > > > > I see that twisted.names allows you to do this, but, having all of twisted > > as dependency to my project when all I need to do is a simple DNS query > > seems a bit extreme. I also found pydns, but that looks fairly outdated and > > unmaintained. > > > > > > Is there not an actively maintained lightweight solution? If not, I will go > > with twisted. > > > > > > > there is a dns modul for Python (I don't know is it part of > > standard Python library or not), on most Linux distribution you > > can find it, eg. in Debian it's called python-dnspython. > > > > It can handle different nameserver, than OS knows - here is a > > sample code: > > > > > > import dns.resolver > > > > r = dns.resolver.Resolver() > > r.namerservers = ['127.0.0.1'] > > # or any other IP, in my case I'm using PDNS, which have two > > # parts: a recursor and a resolver; recursor allows requests only > > # on localhost > > > > mxservers = r.query("python.org", 'MX').response > > > > > > > > > > hth, > > > > > > a.
Indeed, this looks much nicer than both twisted or pydns. I think I'll go with that one. Thanks a lot! -- https://mail.python.org/mailman/listinfo/python-list