如何解决在所有正向查找区域中查询DNS服务器以获取特定IP地址?
我正在为100个以上的正向查找区域运行Windows Server 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,@{n='Zone';e={$zone.ZoneName}}
}
$output | Out-GridView
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。