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,

--
Shaun Venus

Re: Programatically find the configured DNS server by Vadym

Vadym
Wed Feb 22 10:25:04 CST 2006

SGVsbG8sIEJMc3VuZXYhDQoNCiBCPiBDYW4gYW55b25lIHBsZWFzZSB0ZWxsIG1lIGhvdyBJIGNh
biBkbyB0aGlzLCBJIGtub3cgd2l0aCAuTkVUIDIuMCBhbmQNCiBCPiB0aGUgU3lzdGVtLk5ldCBu
YW1lc3BhY2UgRG5zIGlzIGF2YWlsYWJsZSB0aGF0IGNhbiBwcm92aWRlIHRoZSBJUA0KIEI+IGFk
ZHJlc3MgLyBob3N0bmFtZSBvZiB0aGUgc3lzdGVtLCBidXQgSSBuZWVkIG1vcmUgdGhhbiBqdXN0
IHRoaXMgLSBJDQogQj4gd2FudCB0aGUgRE5TIHNlcnZlci4NCg0KdXNlIFdNSSwgbWFrZSBhIHF1
ZXJ5IGZvciBXaW4zMl9OZXR3b3JrQWRhcHRlckNvbmZpZ3VyYXRpb24gIGNsYXNzLg0KRE5TSG9z
dEJOYW1lIHdpbGwgY29udGFpbiB0aGUgaW5mb3JtYXRpb24geW91IG5lZWQuLi4NCg0KVGFrZSBh
IGxvb2sgYXQgKCBodHRwOi8vd3d3LmNvZGVwcm9qZWN0LmNvbS9jc2hhcnAvT2JhRmluZGluZ0lQ
SW5mb3JtYXRpb24uYXNwICkNCg0KDQotLQ0KUmVnYXJkcywgVmFkeW0gU3RldHN5YWsNCnd3dzog
aHR0cDovL3ZhZG15c3QuYmxvZ3Nwb3QuY29t


Re: Programatically find the configured DNS server by jacky

jacky
Wed Feb 22 19:17:03 CST 2006

BLsunev wrote:
> 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

--
Jacky Kwok
jacky@alumni_DOT_cuhk_DOT_edu_DOT_hk
jacky@compose_DOT_com_DOT_hk

RE: Programatically find the configured DNS server by v-terryf

v-terryf
Wed Feb 22 22:30:13 CST 2006

Hi Shaun,
Welcome to MSDN Newsgroup!

I hope the following article is also helpful for you:
Title: C# .NET DNS query component
URL: http://www.codeproject.com/csharp/dnslookupdotnet.asp

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security

--------------------
>Thread-Topic: Programatically find the configured DNS server
>thread-index: AcY3w2GhYTAJzQ1WQgaUkhdBCImaYA==
>X-WBNR-Posting-Host: 217.196.245.2
>From: "=?Utf-8?B?QkxzdW5ldg==?=" <sunev@nospam.nospam>
>Subject: Programatically find the configured DNS server
>Date: Wed, 22 Feb 2006 07:19:32 -0800
>Lines: 14
>Message-ID: <5E511751-B2B6-4360-9B6A-9AAB768F30B6@microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.dotnet.framework
>NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
>Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
>Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework:109057
>X-Tomcat-NG: microsoft.public.dotnet.framework
>
>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,
>
>--
>Shaun Venus
>