Programatically find the configured DNS server

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have some c# code to perform DNS lookups but currently need to provide the
IP address of the DNS server it uses. I would like to be able to identify
the addres of the currently configured DNS server(s) and use this so that the
app will effectively configure itself.

Can anyone please tell me how I can do this, I know with .NET 2.0 and the
System.Net namespace Dns is available that can provide the IP address /
hostname of the system, but I need more than just this - I want the DNS
server.

Thanks in advance,
 
Hello, BLsunev!

B> Can anyone please tell me how I can do this, I know with .NET 2.0 and
B> the System.Net namespace Dns is available that can provide the IP
B> address / hostname of the system, but I need more than just this - I
B> want the DNS server.

use WMI, make a query for Win32_NetworkAdapterConfiguration class.
DNSHostBName will contain the information you need...

Take a look at ( http://www.codeproject.com/csharp/ObaFindingIPInformation.asp )


--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
BLsunev said:
I have some c# code to perform DNS lookups but currently need to provide the
IP address of the DNS server it uses. I would like to be able to identify
the addres of the currently configured DNS server(s) and use this so that the
app will effectively configure itself.

Can anyone please tell me how I can do this, I know with .NET 2.0 and the
System.Net namespace Dns is available that can provide the IP address /
hostname of the system, but I need more than just this - I want the DNS
server.

Thanks in advance,


In Dotnet2,

the namespace "System.Net.NetworkInformation" also provides classes to
easy access the network information.

There is a full sample in Dotnet2 SDK.

http://msdn2.microsoft.com/en-us/library(d=robot)/2xatedhd.aspx
 
Back
Top