IPInterfaceProperties.AnycastAddresses Property

Definition

Gets the anycast IP addresses assigned to this interface.

C#
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public abstract System.Net.NetworkInformation.IPAddressInformationCollection AnycastAddresses { get; }
C#
public abstract System.Net.NetworkInformation.IPAddressInformationCollection AnycastAddresses { get; }

Property Value

An IPAddressInformationCollection that contains the anycast addresses for this interface.

Attributes

Examples

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

C#
public static void DisplayAnycastAddresses()
{
    int count = 0;

    Console.WriteLine("Anycast Addresses");
    NetworkInterface[] adapters  = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in adapters)
    {
        IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
        IPAddressInformationCollection anyCast = adapterProperties.AnycastAddresses;
        if (anyCast.Count >0)
        {

            Console.WriteLine(adapter.Description);
            foreach (IPAddressInformation any in anyCast)
            {
                Console.WriteLine("  Anycast Address .......................... : {0} {1} {2}",
                    any.Address,
                    any.IsTransient ? "Transient" : "",
                    any.IsDnsEligible ? "DNS Eligible" : ""
                );
                count++;
            }
            Console.WriteLine();
        }
    }
    if (count == 0)
    {
        Console.WriteLine("  No anycast addressses were found.");
        Console.WriteLine();
    }
}

Remarks

An anycast address identifies multiple computers. Packets sent to an anycast address are sent to one of the computers identified by the address. Anycast addressing is an IPv6 feature used to update router tables for a group of hosts.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1