views:

242

answers:

2

Hi,

I'd like to know if there's any way to force the System.Net.Dns class to resolve hostnames using a set of custom DNS servers instead of using the ones that are associated with the main network connection.

I suspect that this is only possible using a custom library like DnDns (http://dndns.codeplex.com), but I was hoping this could be done from within .NET.

+2  A: 

No this cannot be done with the .Net Framework. The Dns.Resolve method relies on the internal Win32 APIs which in turn go through the DNS servers associated with the network connection.

In order to get this to work, you'd have to change the DNS servers associated with the network adapter's address.

JaredPar
A: 

You can do this with "JH Software's DNS Client for .NET" - without changing the DNS local servers. See the second code sample at http://www.simpledns.com/dns-client-lib.aspx

Jesper