Hi. I'm trying to set the Alternate DNS Server using .NET. I have managed to set the main DNS server by using this bit of code.
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if ((bool)mo["IPEnabled"])
{
ManagementBaseObject objdns = mo.GetMethodParameters("SetDNSServerSearchOrder");
if (objdns != null)
{
string[] s = { "127.0.0.1" };
objdns["DNSServerSearchOrder"] = s;
mo.InvokeMethod("SetDNSServerSearchOrder", objdns, null);
}
}
}
Now I need to figure out how to set the Alternate DNS Server. Please help. Thanks in advance!