次の方法で共有


IPInterfaceProperties.DnsAddresses プロパティ

定義

このインターフェイスのドメイン ネーム システム (DNS) サーバーのアドレスを取得します。

public:
 abstract property System::Net::NetworkInformation::IPAddressCollection ^ DnsAddresses { System::Net::NetworkInformation::IPAddressCollection ^ get(); };
public abstract System.Net.NetworkInformation.IPAddressCollection DnsAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.IPAddressCollection DnsAddresses { get; }
member this.DnsAddresses : System.Net.NetworkInformation.IPAddressCollection
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
member this.DnsAddresses : System.Net.NetworkInformation.IPAddressCollection
Public MustOverride ReadOnly Property DnsAddresses As IPAddressCollection

プロパティ値

DNS サーバーのアドレスを格納している IPAddressCollection

属性

次のコード例では、ローカル コンピューター上のネットワーク インターフェイスの DNS アドレスを表示します。

void DisplayDnsAddresses()
{
   array<NetworkInterface^>^adapters = NetworkInterface::GetAllNetworkInterfaces();
   System::Collections::IEnumerator^ myEnum11 = adapters->GetEnumerator();
   while ( myEnum11->MoveNext() )
   {
      NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum11->Current);
      IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties();
      IPAddressCollection ^ dnsServers = adapterProperties->DnsAddresses;
      if ( dnsServers->Count > 0 )
      {
         Console::WriteLine( adapter->Description );
         System::Collections::IEnumerator^ myEnum12 = dnsServers->GetEnumerator();
         while ( myEnum12->MoveNext() )
         {
            IPAddress ^ dns = safe_cast<IPAddress ^>(myEnum12->Current);
            Console::WriteLine( "  DNS Servers ............................. : {0}", 
               dns->ToString());
         }
      }
   }
}
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.ToString());
            }
            Console.WriteLine();
        }
    }
}
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

注釈

DNS は、ホスト名を IP アドレスにマップするために使用される階層的な名前付けシステムです。

適用対象