このような問題のトラブルシューティングを行う際に最初に行うべきことの一つは、DNSデバッグログの有効化です。ただし、デバッグログを確認する必要がある場合、非常に困難な作業になります。そこで、PowerShellを使用してDNSデバッグログパーサースクリプトを作成し、作業を容易にしましょう!
PowerShellを使用したDNSデバッグログパーサーの作成方法
デバッグオプションはさまざまありますが、私の場合は動的更新に関する詳細情報が必要です。次は、DNSサーバーの構成例です。

これを有効にすると、指定したファイルパスにログファイルが作成され、次のような形式になります:

線で囲まれた最初の行がIPアドレスで、最後の行が更新を試みたDNSレコードです。わかりやすい理由からこれらはマークされています。選択したオプションによっては、このログファイルは非常に大きくなる可能性があり、読みやすい形式ではありません。
単一のIPをフィルタリングしたり、特定の期間で絞り込んだりするにはどうすればよいでしょうか?デフォルトのログファイルではそれはできません。これが私がPowerShellでDNSデバッグログパーサースクリプトを作成した理由です。
以下のスクリプトは、このログファイルを解析して、次のような見やすいCSVファイルに変換します:

それはずっと良く見えますね。スクリプトはログファイルをエラーを探し、日付、IP、エラーを抽出して、きれいにフォーマットされたCSVに配置します。それに加えて、すべてのDNSサーバーのIPを除外します。
どのオプションを選んでも、なぜかDNSサーバーのIP自体が表示され続けることがわかりました。問題のあるDNSレコードの更新に問題があるクライアントのIPアドレスが知りたいだけです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requires -Module ActiveDirectory | |
$dnsServer = ‘‘ ## This is the server name as a NETBIOS or FQDN | |
$OutputFilePath = ‘C:\DNSDebugLogSummary.csv‘ ## The CSV file that will be created | |
## The log file you specified in the debug logging dialog box | |
$DnsDebugLogFilePath = “\$dnsServer\c$\DnsDebugLog.log“ | |
## Find all of the DNS server IPs in the current domain | |
$DnsServerIPs = ((Get-ADDomain).ReplicaDirectoryServers | Resolve-DnsName).IPAddress | |
Write-Verbose –Message “Found DNS servers $($DnsServerIPs -join ‘,‘)“ | |
## Find all lines in the log file that don’t contain the strings ‘NOERROR’ or are blank. This | |
## retrieves only the lines with errors in them. | |
Select-String –Pattern ‘NOERROR|^\s*‘ –Path $DnsDebugLogFilePath -NotMatch | foreach { | |
try { | |
## Find lines containing an IP address | |
if ($_.Line -match ‘\b(?:\d{1,3}\.){3}\d{1,3}\b‘) { | |
Write-Verbose –Message ‘Found line with IP address.‘ | |
$IP = $Matches[0] | |
## If the IP isn’t a DNS server it must be a client IP | |
if ($DnsServerIPs -notcontains $IP) { | |
Write-Verbose “Processing IP ‘$IP‘“ | |
$Split = $_.Line.Split(‘ ‘) | |
$Date = $Split[0] | |
$Time = $Split[1] + $Split[2] | |
$Err = [regex]::Match($_.Line, ‘\[(.*)\]‘).Groups[1].Value | |
[pscustomobject]@{ ‘Date‘ = “$Date $Time“; ‘IP‘ = $IP; ‘Error‘ = $Err } | |
} | |
} | |
} catch { | |
Write-Warning $_.Exception.Message | |
} | |
} | Export-Csv –Path $OutputFilePath –Append –NoTypeInformation |