IPAddressInformation.IsDnsEligible 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个 Boolean 值,该值指示 Internet 协议 (IP) 地址出现在域名系统 (DNS) 服务器数据库中时是否有效。
public:
abstract property bool IsDnsEligible { bool get(); };
public abstract bool IsDnsEligible { get; }
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public abstract bool IsDnsEligible { get; }
member this.IsDnsEligible : bool
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
member this.IsDnsEligible : bool
Public MustOverride ReadOnly Property IsDnsEligible As Boolean
属性值
如果地址可以出现在 DNS 数据库,则为 true
;否则为 false
。
- 属性
示例
下面的代码示例显示本地计算机上网络接口的任意广播地址。
void DisplayAnycastAddresses()
{
int count = 0;
Console::WriteLine( "Anycast Addresses" );
array<NetworkInterface^>^adapters = NetworkInterface::GetAllNetworkInterfaces();
System::Collections::IEnumerator^ myEnum13 = adapters->GetEnumerator();
while ( myEnum13->MoveNext() )
{
NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum13->Current);
IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties();
IPAddressInformationCollection ^ anyCast = adapterProperties->AnycastAddresses;
if ( anyCast->Count > 0 )
{
Console::WriteLine( adapter->Description );
System::Collections::IEnumerator^ myEnum14 = anyCast->GetEnumerator();
while ( myEnum14->MoveNext() )
{
IPAddressInformation ^ any = safe_cast<IPAddressInformation ^>(myEnum14->Current);
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 addresses were found.");
Console::WriteLine();
}
}
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();
}
}
Public Shared Sub DisplayAnycastAddresses()
Dim count as Integer = 0
Console.WriteLine("Anycast Addresses")
Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
Dim adapter As NetworkInterface
For Each adapter In adapters
Dim adapterProperties As IPInterfaceProperties = adapter.GetIPProperties()
Dim anyCast As IPAddressInformationCollection = adapterProperties.AnycastAddresses
If anyCast.Count > 0 Then
Console.WriteLine(adapter.Description)
Dim any As IPAddressInformation
For Each any In anyCast
Console.WriteLine(" Anycast Address .......................... : {0} {1} {2}", any.Address, IIf(any.IsTransient, "Transient", ""), IIf(any.IsDnsEligible, "DNS Eligible", ""))
'TODO: For performance reasons this should be changed to nested IF statements
'TODO: For performance reasons this should be changed to nested IF statements
count += 1
Next any
Console.WriteLine()
End If
Next adapter
if count = 0 then
Console.WriteLine(" No anycast addresses were found.")
Console.WriteLine()
End if
End Sub
注解
范围 169.254.0.0 到 169.254.255.255 的地址不符合 DNS 条件。 这些地址保留给 APIPA) (自动专用 IP 寻址。