Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win32 ,Multiple NIC computer , different DNS per NIC , how gethostbyname behaves?

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 ?

like image 492
dweeves Avatar asked Nov 05 '22 19:11

dweeves


1 Answers

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.

like image 86
Mike Avatar answered Nov 15 '22 06:11

Mike