Order of addresses returned by socket.gethostbyname_ex()
rosuav at gmail.com
Mon Aug 22 06:36:12 EDT 2011
On Mon, Aug 22, 2011 at 11:06 AM, Cameron Simpson <cs at zip.com.au> wrote:
> What if you queried your routing table instead? Usually there's just one
> default route, and hopefully it would be configured to use the "best"
I wouldn't necessarily trust even this, on Windows. I've lately had
the most insane trouble getting my XP laptop to function properly as a
proxy - LAN connection has the default gateway, wifi has only
192.168.* - and Windows kept on trying to send DNS queries out on the
wireless connection, and then wondered why it didn't get a result.
Explicit is better than implicit. Instead of using the order, have a
config file that chooses the one(s) you want by name or IP address. Of
course, if you're on Unix/Linux, you can use the interface name (eth0,
eth1, etc) with a fair degree of reliability.
More information about the Python-list