获取DNS服务器列表
public static void DisplayDnsAddresses()
{
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{
IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
IPAddressCollection dnsServers = adapterProperties.DnsAddresses;
if (dnsServers.Count > 0)
{
Console.WriteLine(adapter.Description); //网卡的信息
foreach (IPAddress dns in dnsServers)
{
Console.WriteLine(" DNS Servers ............................. : {0} )",dns); //所配置的DNS
}
}
}
}
上面这些类在2.0中可以直接使用