Getting client machine's configured DNS IP addresses

  • Thread starter Thread starter Chris Morse
  • Start date Start date
C

Chris Morse

Does anyone know how to determine the DNS servers for a client
machine? I'd like this to work on any .NET enabled platform, which
basically means everything except Windows 95.

Researching this is a nightmare. There are many place to look
depending on the machine's configuration. On Windows 2000, there's
one place if you have the TCP/IP settings specified, another place if
you're using DHCP. On Windows 98SE, the only place I found a
reference to the DNS IP address, in the registry, was in a custom
place defined by my portable's PCMCIA card driver.

I've heard of an undocumented function in WinSock called WsControl(),
which apparently is used by the "winipcfg" utility. Not sure if
"ipconfig" on NT/2000 uses that too, but probably does.

I found this info on this page:
http://homepages.nildram.co.uk/~phekda/richdawe/dl/ipdata.txt

I'd like my program to automatically detect the current DNS servers
configured for the client machine. Certainly there is a way to do
this, no?!

// CHRIS
 
Hi Chris,

I dont know it, but what I know is that there is a class with a lot of
information about this

System.Net.Dns

Maybe you can find it there,

Cor
 
Hi Chris,

I dont know it, but what I know is that there is a class with a lot of
information about this

System.Net.Dns

Maybe you can find it there,

Cor


Unfortunately, the System.Net.Dns namespace provides *limited* DNS
functionality. It allows you to basically convert from hostname to IP
and vice-versa.

There is no way to DETERMINE WHICH DNS SERVERS IT USES, let alone do
any other kind of DNS lookup.

I found another reference to WsControl() in the WinSock Programmers
FAQ, and apparently Microsoft's attitude toward it is that if you want
to find your current DNS IP's, then run winipcfg.exe (or ipconfig.exe
on NT/2000) in BATCH mode and capture the text output to a file.
THEN, parse the file for the information. What a whacky way to do it!


// CHRIS
 
Does anyone know how to determine the DNS servers for a client
machine? I'd like this to work on any .NET enabled platform, which
basically means everything except Windows 95.

Researching this is a nightmare. There are many place to look
depending on the machine's configuration. On Windows 2000, there's
one place if you have the TCP/IP settings specified, another place if
you're using DHCP. On Windows 98SE, the only place I found a
reference to the DNS IP address, in the registry, was in a custom
place defined by my portable's PCMCIA card driver.

I've heard of an undocumented function in WinSock called WsControl(),
which apparently is used by the "winipcfg" utility. Not sure if
"ipconfig" on NT/2000 uses that too, but probably does.

I found this info on this page:
http://homepages.nildram.co.uk/~phekda/richdawe/dl/ipdata.txt

I'd like my program to automatically detect the current DNS servers
configured for the client machine. Certainly there is a way to do
this, no?!

// CHRIS

Chris,

I haven't looked at them for a while, but there are the IP Helper API
calls. In fact, I have used IcmpSendEcho to do pings from C#. I'm
not sure if there is anything specific to DNS in there - but it maybe
worth checking into:

http://msdn.microsoft.com/library/d.../iphlp/iphlp/ip_helper_function_reference.asp

HTH
 
Back
Top