IPInterfaceProperties.DnsAddresses Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the addresses of Domain Name System (DNS) servers for this interface.

Namespace:   System.Net.NetworkInformation
Assembly:  System (in System.dll)

public abstract IPAddressCollection DnsAddresses { get; }

Property Value

Type: System.Net.NetworkInformation.IPAddressCollection

A IPAddressCollection that contains the DNS server addresses.

DNS is a hierarchical naming system used to map host names to IP addresses.

The following code example displays the DNS addresses for the network interfaces on the local computer.

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)
            foreach (IPAddress dns in dnsServers)
                Console.WriteLine("  DNS Servers ............................. : {0}", 

.NET Framework
Available since 2.0
Return to top