다음을 통해 공유


IPInterfaceProperties.DhcpServerAddresses 속성

정의

이 인터페이스에 대한 DHCP(Dynamic Host Configuration Protocol) 서버의 주소를 가져옵니다.

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

속성 값

DHCP 서버에 대한 주소 정보가 들어 있는 IPAddressCollection이거나, 서버를 찾을 수 없는 경우 빈 배열입니다.

특성

예제

다음 코드 예제에서는 로컬 컴퓨터의 네트워크 인터페이스에 대한 DHCP 주소 정보를 표시합니다.

void DisplayDhcpServerAddresses()
{
   Console::WriteLine( "DHCP Servers" );
   array<NetworkInterface^>^adapters = NetworkInterface::GetAllNetworkInterfaces();
   System::Collections::IEnumerator^ myEnum19 = adapters->GetEnumerator();
   while ( myEnum19->MoveNext() )
   {
      NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum19->Current);
      IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties();
      IPAddressCollection ^ addresses = adapterProperties->DhcpServerAddresses;
      if ( addresses->Count > 0 )
      {
         Console::WriteLine( adapter->Description );
         System::Collections::IEnumerator^ myEnum20 = addresses->GetEnumerator();
         while ( myEnum20->MoveNext() )
         {
            IPAddress^ address = safe_cast<IPAddress^>(myEnum20->Current);
            Console::WriteLine( "  Dhcp Address ............................ : {0}", 
               address );
         }
         Console::WriteLine();
      }
   }
}
public static void DisplayDhcpServerAddresses()
{
    Console.WriteLine("DHCP Servers");
    NetworkInterface[] adapters  = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in adapters)
    {

        IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
        IPAddressCollection addresses = adapterProperties.DhcpServerAddresses;
        if (addresses.Count >0)
        {
            Console.WriteLine(adapter.Description);
            foreach (IPAddress address in addresses)
            {
                Console.WriteLine("  Dhcp Address ............................ : {0}",
                    address.ToString());
            }
            Console.WriteLine();
        }
    }
}
Public Shared Sub DisplayDhcpServerAddresses() 
    Console.WriteLine("DHCP Servers")
    Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
    Dim adapter As NetworkInterface
    For Each adapter In  adapters
        
        Dim adapterProperties As IPInterfaceProperties = adapter.GetIPProperties()
        Dim addresses As IPAddressCollection = adapterProperties.DhcpServerAddresses
        If addresses.Count > 0 Then
            Console.WriteLine(adapter.Description)
            Dim address As IPAddress
            For Each address In  addresses
                Console.WriteLine("  Dhcp Address ............................ : {0}", address.ToString())
            Next address
            Console.WriteLine()
        End If
    Next adapter

End Sub

설명

DHCP(동적 호스트 구성 프로토콜)를 사용하면 컴퓨터가 정적(고정) 네트워크 주소를 사용하는 것이 아니라 DHCP 서버에서 네트워크 주소를 가져올 수 있습니다. DHCP 서버는 주소를 영구적으로 할당하지 않습니다. 대신 컴퓨터에 사용 가능한 여러 주소 중 하나를 일시적으로 사용합니다.

적용 대상