繁体   English   中英

使用 Powershell 进行奇怪的 DNS 记录重复?

[英]Strange DNS record duplication with Powershell?

最近在使用本机 Powershell DNS commandlet 时,特别是 Get-DNSServerResourceRecord,我注意到一些奇怪的东西对我来说没有意义。

当我使用本机 DNS 工具、LDAP 查询工具甚至 ADSIedit 查看我的区域时,我只看到一个代表给定主机名的 DNS 对象。

但是,当我对 Powershell 执行相同操作时,我反而为给定主机获取了两个对象,一个用于 NETBIOS 名称,另一个用于 FQDN。 所有其他属性都相同,包括 IP。

例如,如果我有一台名为computer1的计算机:这就是我所看到的。

PS C:\> Get-DnsServerResourceRecord -ZoneName 'mydomain.local' -RRType A -ComputerName 'DNSServer1' | Where-Object {$_.hostname -like "Computer1*"}  | fl *


DistinguishedName     : DC=computer1.mydomain.local,DC=mydomain.local,cn=MicrosoftDNS,DC=DomainDnsZones,DC=mydomain,DC=local
HostName              : COMPUTER1.mydomain.local
RecordClass           : IN
RecordData            : DnsServerResourceRecordA
RecordType            : A
Timestamp             :
TimeToLive            : 01:00:00
Type                  : 1
PSComputerName        :
CimClass              : root/Microsoft/Windows/DNS:DnsServerResourceRecord
CimInstanceProperties : {DistinguishedName, HostName, RecordClass, RecordData...}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

DistinguishedName     : DC=computer1,DC=mydomain.local,cn=MicrosoftDNS,DC=DomainDnsZones,dc=mydomain,dc=local
HostName              : COMPUTER1
RecordClass           : IN
RecordData            : DnsServerResourceRecordA
RecordType            : A
Timestamp             :
TimeToLive            : 01:00:00
Type                  : 1
PSComputerName        :
CimClass              : root/Microsoft/Windows/DNS:DnsServerResourceRecord
CimInstanceProperties : {DistinguishedName, HostName, RecordClass, RecordData...}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties


我很困惑为什么 Powershell 显示这个以及它实际上是从哪里拉出来的。 我无法使用本机 LDAP 工具(甚至是 ADFind)找到那些 FQDN 对象。

这是 Powershell DNS cmdlet 的一些奇怪的工件/错误吗? 或者 DNS 记录是否存储给定主机的双重条目,但仅使用本机工具显示一个条目?

这对我来说都没有意义,因为我不希望 cmdlet 只是动态地组成 DN 值,而且这不会发生在所有主机记录上。后者似乎不可能,因为这不会发生在所有主机记录上区。 与使用 fqdn 相比,我有大约 100 条记录(10926 对 10824)。

编辑如果有帮助,这里是对同一对象(和通配符)的 ADFind 查询。

C:\temp>adfind -h dnsserver1 -domaindns -f "(&(name=computer1*))" name

AdFind V01.57.00cpp Joe Richards (support@joeware.net) November 2021

Using server: dnsserver1.mydomain.local:389
Directory: Windows Server 2016
Base DN: DC=DomainDnsZones,DC=ad,DC=ewsad,DC=net

dn:DC=computer1,DC=mydomain.local,CN=MicrosoftDNS,DC=DomainDnsZones,DC=mydomain,DC=local
>name: computer1


1 Objects returned

我可以确认这种行为。

在 powershell 中,这会为许多计算机返回 2 个结果(也许是全部,我没有检查)

Get-DnsServerResourceRecord -ZoneName 'domain.com' -RRType A -ComputerName dnserver1 | where hostname -like Computer1*

DistinguishedName     : DC=Computer1.domain.com,DC=domain.com,cn=MicrosoftDNS,DC=DomainDnsZones,DC=domain,DC=com
HostName              : Computer1.domain.com
RecordClass           : IN
RecordData            : DnsServerResourceRecordA
RecordType            : A
Timestamp             : 12/8/2022 9:00:00 AM
TimeToLive            : 00:20:00
Type                  : 1
PSComputerName        :
CimClass              : root/Microsoft/Windows/DNS:DnsServerResourceRecord
CimInstanceProperties : {DistinguishedName, HostName, RecordClass, RecordData...}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

DistinguishedName     : DC=Computer1,DC=domain.com,cn=MicrosoftDNS,DC=DomainDnsZones,DC=domain,DC=com
HostName              : Computer1
RecordClass           : IN
RecordData            : DnsServerResourceRecordA
RecordType            : A
Timestamp             : 12/8/2022 9:00:00 AM
TimeToLive            : 00:20:00
Type                  : 1
PSComputerName        :
CimClass              : root/Microsoft/Windows/DNS:DnsServerResourceRecord
CimInstanceProperties : {DistinguishedName, HostName, RecordClass, RecordData...}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

但是 dsquery 会产生一条记录。

dsquery computer -name computer1* -s dnsserver1

"CN=Computer1,OU=Computers,DC=domain,DC=com"

您可以确认其中只有一个是真实的 AD 对象。

$recordlist = Get-DnsServerResourceRecord -ZoneName 'domain.com' -RRType A -ComputerName dnserver1 | where hostname -like Computer1*

foreach($record in $recordlist){
    Write-Host "Checking DN $($record.DistinguishedName)" -ForegroundColor Cyan
    
    $found = $record.DistinguishedName |
        Get-ADObject -ErrorAction SilentlyContinue

    if($found){
        Write-Host "Record found in AD" -ForegroundColor Green
    }
    else{
        Write-Host "Record not in AD" -ForegroundColor DarkGray
    }
}

因此,到目前为止,我必须得出结论,证据确实表明Get-DnsServerResourceRecord添加带有 FQDN 的重复记录。 希望有人能找到或知道为什么以这种方式实施。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM