views:

257

answers:

3

Hello SO,

On a win32 multiple nic computer, how to force DNS resolving through gethostbyname() on a specific nic if all nics have different DNS configured and have the same metric ?

Otherwise, how to know which DNS will be used to resolve names each time a gethostbyname() call will be performed by the application ?

A: 

That might be better answered at http://serverfault.com/ It's a site geared more toward administering a machine. SO is best for programming.

Patrick Regan
i duplicated the question to SF, but SO programmer opinion may be of interest since i want to know if i will have to rewrite a gethostbyname() specific function for my need
dweeves
+1  A: 

You can't do this, at least I'm fairly certain you can't specify an interface to send out the queries from using gethostbyname() or any of the standard socket utilities. (There might be a very esoteric win32 option for this, but I'm betting against it)

If you absolutely need this functionality, you'll need to pick a third party DNS library that provides you with such an ability ... or even write one from scatch.

The library will need to provide you with a means of binding the UDP socket that will be issuing the DNS queries to a specified address.

There also might be a way of configuring Windows to issue DNS queries from an interface using system settings, but I strongly doubt there is a means of doing this from within a program.

Mike
i was expecting such a response , but before reimplementing my own variant of gethostbyname with socket bind, i wanted to make sure it was the only option. thanks for the response !
dweeves
you should leave the question open for a while however, i don't know everything :)
Mike
A: 

Consider to use raw sockets and implement your own DNS query mechanism.

Lars D