Skip to main content
GameDev.net gamedev.net
🔒 Locked

DNS Server List

Started by VBStrider Jul 4, 2007 at 11:54 AM 3 replies 1.7k views
Original Post
VBStrider
VBStrider
How do you get the list of DNS servers that is associated with a network adapter? I have tried GetAdaptersAddresses(), but I would prefer an option that is not part of the .NET framework if possible. VBStrider
hplus0603
hplus0603
There is not a well-defined or platform independent way to get that data.

If you can limit yourself to Windows XP or later, you can use the .NET function you suggest, or you can parse the output of "ipconfig /all". You can also do what ipconfig /all does internally, which is calling GetAdaptersAddresses(), which returns a IP_ADAPTER_ADDRESSES structure. It's part of the Ip Helper library on Windows XP and later.
enum Bool { True, False, FileNotFound };
VBStrider
VBStrider
Hmmm, how does GetAdaptersAddresses() do it? Is it simply something special that windows lets only the IP helper library do? It does not matter if the code is not platform independent, I currently just need it to run on at least Windows XP.

VBStrider
hplus0603
hplus0603
I imagine it goes groping through the registry, and whatever networking configuration files there are (which may be provider dependent). It's likely different on XP and on Vista, too.

Why not just call the Win32 function GetAdaptersAddresses() in iphelper?
enum Bool { True, False, FileNotFound };
VBStrider
VBStrider
I'd like to do it as manually as possible so that I know what it is doing under the hood. Once I have done that, I'll feel like I have earned the right to use that function.

Also, the fewer .dll files that the user is required to have, the better in my opinion.

VBStrider

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.