[Mono-list] How to get the DNS server address?
cxcxcxcx at gmail.com
Fri Nov 28 07:53:03 EST 2008
Hello. I want to get the default DNS server address currently used. In
Windows and .Net 2.0 , I can get it with the following code:
public static IPAddressCollection DiscoverDnsServerAddresses()
NetworkInterface nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface nic in nics)
if ( (nic.OperationalStatus == OperationalStatus.Up) && (nic.Speed > 0)
(nic.NetworkInterfaceType != NetworkInterfaceType.Loopback)&&
(nic.NetworkInterfaceType != NetworkInterfaceType.Tunnel))
But in mono, nic.GetIPProperties().DnsAddresses; returns a collection with
nothing in it.
I guess it's because that in Linux DNS server address is not configured for
each "Network Interface", but globally by /etc/resolv.conf
I wonder if there are ways to get the DNS Servers Address in Linux with mono
without parse /etc/resolv.conf mannualy?
View this message in context: http://www.nabble.com/How-to-get-the-DNS-server-address--tp20733912p20733912.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list