簡體   English   中英

在所有正向查找區域中查詢 DNS 服務器以獲取特定 IP 地址?

[英]Query DNS server for specific IP address in all Forward Lookup Zones?

我正在為超過 100 個正向查找區域運行 Windows 服務器 DNS。 我需要找到,哪個正向查找 ZOnes 或 DNS 條目正在使用特定的 IP 地址?

因此輸入將是: 192.0.2.4 (任何 IP 地址)結果:任何正向查找區域及其包含上述 IP 地址的 DNS 條目。

這里的目標是找到由於舊的 IP 地址而不再有效的 DNS 條目。

一個不起作用的例子:

Get-DnsServerResourceRecord -ZoneName * | Where-Object {$_.IPv4Address.IPAddressToString -contains '192.0.2.4' }

您可以先查詢您的區域並遍歷它們:

$zones = Get-DnsServerZone | where {!$_.IsReverseLookupZone -and $_.ZoneType -eq 'Primary'}
foreach ($zone in $zones) {
    Get-DnsServerResourceRecord -ZoneName $zone.ZoneName |
        Where {$_.RecordData.Ipv4Address.IPAddressToString -contains '192.0.2.4'} |
            Select HostName,RecordType,Type,RecordData,Timestamp,TimeToLive,@{n='Zone';e={$zone.ZoneName}}
}

如果你想要一個網格視圖,你可以使用Out-Gridview

$zones = Get-DnsServerZone | where {!$_.IsReverseLookupZone -and $_.ZoneType -eq 'Primary'}
$output = foreach ($zone in $zones) {
    Get-DnsServerResourceRecord -ZoneName $zone.ZoneName |
        Where {$_.RecordData.Ipv4Address.IPAddressToString -contains '192.0.2.4'} |
            Select HostName,RecordType,Type,RecordData,Timestamp,TimeToLive,@{n='Zone';e={$zone.ZoneName}}
}
$output | Out-GridView

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM