This documentation is archived and is not being maintained.

IPAddressInformation Class

Provides information about a network interface address.

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

'Declaration
Public MustInherit Class IPAddressInformation
'Usage
Dim instance As IPAddressInformation

You do not create instances of this class; instances are returned by methods in the IPInterfaceProperties class.

The following code example displays the Domain Name Service (DNS) addresses for the network interfaces on the local computer.

Public Shared Sub DisplayDnsAddresses() 
    Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
    Dim adapter As NetworkInterface
    For Each adapter In  adapters

        Dim adapterProperties As IPInterfaceProperties = adapter.GetIPProperties()
        Dim dnsServers As IPAddressCollection = adapterProperties.DnsAddresses
        If dnsServers.Count > 0 Then
            Console.WriteLine(adapter.Description)
            Dim dns As IPAddress
            For Each dns In  dnsServers
                Console.WriteLine("  DNS Servers ............................. : {0}",dns.ToString() )
            Next dns
        End If 
    Next adapter

End Sub 'DisplayDnsAddresses
void DisplayDnsAddresses()
{
    NetworkInterface* adapters[]  = NetworkInterface::GetAllNetworkInterfaces();
    System::Collections::IEnumerator* myEnum11 = adapters->GetEnumerator();
    while (myEnum11->MoveNext())
    {
        NetworkInterface* adapter = __try_cast<NetworkInterface*>(myEnum11->Current);

        IPInterfaceProperties* adapterProperties = adapter->GetIPInterfaceProperties();
        IPAddressInformationCollection* dnsServers = adapterProperties->DnsAddresses;
        if (dnsServers->Count > 0)
        {
            Console::WriteLine(adapter->Description);
            System::Collections::IEnumerator* myEnum12 = dnsServers->GetEnumerator();
            while (myEnum12->MoveNext())
            {
                IPAddressInformation* dns = __try_cast<IPAddressInformation*>(myEnum12->Current);
                Console::WriteLine(S"  DNS Servers ............................. : {0} ({1} {2})", 
                    dns->Address,
                    dns->IsTransient ? S"Transient" : S"", 
                    dns->IsDnsEligible ? S"DNS Eligible" : S""
                    );
            }
        }
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: