DNS query against a specific server.

Chris Angelico rosuav at gmail.com
Mon Sep 30 08:56:40 EDT 2013


On Mon, Sep 30, 2013 at 10:45 PM, Michel Albert <exhuma at gmail.com> wrote:
> I know I may be splitting hairs. Any of the mentioned solutions are fine. But I am curious to see if something like this is not yet implemented in a more standard way. I was surprised to see that ``gethostbyname`` does not take an optional parameter for this task.

gethostbyname is a simple function with not much flexibility. (You
can't, for instance, look up a TXT record.) For anything more complex,
you want a proper DNS implementation.

There are a few Python DNS modules. It means adding another
dependency, but perhaps not as large as twisted. And of course, you
could always manually send UDP packets and listen for responses, but
that seems a little unnecessary :)

ChrisA



More information about the Python-list mailing list