IPInterfaceProperties.DhcpServerAddresses Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает адреса DHCP-серверов для данного интерфейса.
public:
abstract property System::Net::NetworkInformation::IPAddressCollection ^ DhcpServerAddresses { System::Net::NetworkInformation::IPAddressCollection ^ 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; }
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")>]
member this.DhcpServerAddresses : System.Net.NetworkInformation.IPAddressCollection
member this.DhcpServerAddresses : System.Net.NetworkInformation.IPAddressCollection
Public MustOverride ReadOnly Property DhcpServerAddresses As IPAddressCollection
Значение свойства
Объект IPAddressCollection, содержащий адреса DHCP-серверов, или пустой массив, если серверы не обнаружены.
- Атрибуты
Примеры
В следующем примере кода отображаются сведения о DHCP-адресе для сетевых интерфейсов на локальном компьютере.
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-сервер не назначает адреса окончательно; Вместо этого он временно использует один из нескольких доступных адресов компьютера.