Subject: DNS server selection procedure for WIN32

DNS server selection procedure for WIN32

From: herman bastiaens <hermy_b_at_hotmail.com>
Date: Wed, 21 Mar 2007 16:29:20 +0000

Hi all,

I'm using ares for DNS lookups but the wrong DNS server is used in the
following scenario:
- connect to a wireless network with public DNS servers (that is DNS servers
with a public IP), no wired connection
- plug in the network cable and connect to an internal network with private
DNS servers (servers with private IP)
- turn off radio for the wireless connection (do not disable the adapter)
- lookup an internal domain name (ex. foo.intern.company.com)

ares will now use the public DNS server, associated with the wireless
connection before the radio was turned off, so the internal name is not
found. However, nslookup (executed from the command line) does use the
correct server and the lookup succeeds.

I believe this behaviour is caused by the way the DNS servers are gathered.
This happens in
get_iphlpapi_dns_info, where GetNetworkParams is called to get a list of the
DNS servers. The DNS server associated with the wireless connection will be
listed (and tried) first (at least, on my computer).
I don't know how nslookup manages to find the "right" DNS server, but I
suspect there is a filtering mechanism applied to the list of DNS servers
(ex. exclude DNS servers for wireless connections with radio off) or they
use a different ordering (perhaps provided by GetAdapterOrderMap?) or
compare subnet masks between the local IP and IP of the DNS server or ...

Has anyone else encountered similar problems? Does anyone know a decent
solution for these kind of situations (not uncommon for company networks)?

Any help, comments, ideas... are appreciated.

Thanks in advance,

Herman Bastiaens

_________________________________________________________________
Looking for an old friend? You may find him in your friends' friends list !
http://spaces.live.com/default.aspx?page=Ed01&ss=True
Received on 2007-03-21