Which DNS Server

The domain name system works my moving up a chain of DNS servers one-by-one, until the domain-to-IP mapping entry being looked for is found. Usually this process starts off at your ISP, and works it way towards the 13 (dont quote me on that exact number) root DNS servers run by UUNET and other large providers.

You can determine the DNS servers that your computer primarily uses by typing the following at a command prompt:

Code:
ipconfig /all

Getting this information in .NET is a different story though. Other than an unmanaged solution I believe youre out of luck.
 
Thanks, are the root server IP at UUNET static? I would like to hard-code them into my component as the default DSN servers.
 
This sounds like a bad idea to me - why would you hardcode those? The whole point of DNS is that it should be automatic, traversing a tree to get the desired result, as Derek said.
 
I dont want to hard code these, but I do need to solve the problem (ie. I need to have a DNS ip at runtime).

If I can get the machines Primary DNS IP that would be ideal, but failing that I will use these. I plan to allow the user to override these.

Any further help would be much appreciated
 
I think the question that both Divil and I have is why you would need a DNS server IP in the first place. Care to enlighten us?
 
Sure, I am writing a email validation component which validates the addresses by chatting with the mail server.

I need a DNS IP so that I can get the email servers mx record.
 
Im positive theres a way to do this using WSALookupServiceBegin/Next however my mind is drawing a blank. Have a look into those two functions and let me know if you find anything, as I just dont have the time.

Also, while I dont consider this a perfect solution, you can locate the DNS server IPs under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{guid}\

Youd be looking for values named "NameServer", however that value is not present under all of the contained keys.
 
Back
Top