我已经在DNS服务器上启用debugging日志logging选项 ,我试图通过在dns.log输出parsing。 以下是technet关于如何使用服务器debugging日志logging选项的指南 ,但我无法find任何权威性的标准格式的每个字段将是什么,更不用说当详细信息包括在内。
下面是问题中的一个示例日志行在Windows DNSdebugging日志中,括号中的数字是什么意思? :
6/5/2013 10:00:32 AM 0E70 PACKET 00000000033397A0 UDP Rcv 10.161.60.71 5b47 Q [0001 D NOERROR] A (12)somecomputer(6)domain(3)com(0)
不幸的是,这个答案没有涉及其他领域的任何意思。
Technet的“DNS工作原理”对某些字段进行了很好的审查,但没有针对debugging日志格式。
什么是所有的领域?
分析信息的PowerShell脚本的奖励点。
注意 :这个答案可能是不完整的。 尽可能多地添加尽可能多的信息以帮助携带火炬,但我已经将其添加为社区Wiki,希望其他用户更新不完整或不正确的信息。
根据DNSdebugging日志dns.log Format Review的问题 ,字段映射如下
Date and Time Type Prot Dir Request IP R/Q Flag Record Domain 6/5/2013 10:00:32 AM 0E70 PACKET 00000000033397A0 UDP Rcv 10.161.60.71 5b47 Q [0001 D NOERROR] A (12)somecomputer(6)domain(3)com(0)
以下是字段级别信息的列表:
以下是每个类别的潜在查询值列表:
标志查询 :
0 – 没有错误; 成功更新。 1 – 格式错误; DNS服务器不理解更新请求。 0x2 – DNS服务器遇到内部错误,例如转发超时 0x3 – 应该存在的名称不存在。 0x4 – DNS服务器不支持指定的操作码。 0x5 – DNS服务器拒绝执行更新,因为 0x6 – 不应该存在的名称存在。 0x7 – 不存在的资源logging集。 0x8 – 应该存在的资源logging集不存在。 0x9 – 对于区域部分中指定的区域,DNS服务器不具有权威性。 0xA – “先决条件”或“更新”部分中使用的名称不在“区域”部分指定的区域内。 loggingtypes查找 :
0x01 – 主机logging 0x02 – 名称服务器logging 0x05 – 别名logging 0x0C – 反向查找logging 0x0F – 邮件交换logging 0x21 – 服务logging 0xFB – 增量区域传输logging 0xFC – 标准区域传输logging 0xFF – 所有logging域 这是来自Arun Sabale的Read DNSdebugging日志中的cmdlet, 并以可读的CSV格式生成输出 。
运行cmdlet之后,可以像这样调用它:
Get-DNSDebugLog -DNSLog ".\DnsDebug.log" | Export-Csv .\ProperlyFormatedLog.csv
脚本 :
########################################################################### # NAME: read DNS debug logs # AUTHOR: Arun Sabale # COMMENT: # VERSION HISTORY: # 1.0 - Initial release ########################################################################### function Get-DNSDebugLog { <# .SYNOPSIS This cmdlet parses a Windows DNS Debug log. .DESCRIPTION When a DNS log is converted with this cmdlet it will be turned into objects for further parsing. .EXAMPLE Get-DNSDebugLog -DNSLog ".\Something.log" | Format-Table Outputs the contents of the dns debug file "Something.log" as a table. .EXAMPLE Get-DNSDebugLog -DNSLog ".\Something.log" | Export-Csv .\ProperlyFormatedLog.csv Turns the debug file into a csv-file. .PARAMETER DNSLog Path to the DNS log or DNS log data. Allows pipelining from for example Get-ChildItem for files, and supports pipelining DNS log data. #> [CmdletBinding()] param( [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [Alias('Fullname')] [string] $DNSLog = "StringMode") BEGIN { } PROCESS { $TheReverseRegExString="\(\d\)in-addr\(\d\)arpa\(\d\)" ReturnDNSLogLines -DNSLog $DNSLog | % { if ( $_ -match "^\d\d" -AND $_ -notlike "*EVENT*") { $Date=$null $Time=$null $DateTime=$null $Protocol=$null $Client=$null $SendReceive=$null $QueryType=$null $RecordType=$null $Query=$null $Result=$null $Date=($_ -split " ")[0] # Check log time format and set properties if ($_ -match ":\d\d AM|:\d\d PM") { $Time=($_ -split " ")[1,2] -join " " $Protocol=($_ -split " ")[7] $Client=($_ -split " ")[9] $SendReceive=($_ -split " ")[8] $RecordType=(($_ -split "]")[1] -split " ")[1] $Query=($_.ToString().Substring(110)) -replace "\s" -replace "\(\d?\d\)","." -replace "^\." -replace "\.$" $Result=(((($_ -split "\[")[1]).ToString().Substring(9)) -split "]")[0] -replace " " } elseif ($_ -match "^\d\d\d\d\d\d\d\d \d\d:") { $Date=$Date.Substring(0,4) + "-" + $Date.Substring(4,2) + "-" + $Date.Substring(6,2) $Time=($_ -split " ")[1] -join " " $Protocol=($_ -split " ")[6] $Client=($_ -split " ")[8] $SendReceive=($_ -split " ")[7] $RecordType=(($_ -split "]")[1] -split " ")[1] $Query=($_.ToString().Substring(110)) -replace "\s" -replace "\(\d?\d\)","." -replace "^\." -replace "\.$" $Result=(((($_ -split "\[")[1]).ToString().Substring(9)) -split "]")[0] -replace " " } else { $Time=($_ -split " ")[1] $Protocol=($_ -split " ")[6] $Client=($_ -split " ")[8] $SendReceive=($_ -split " ")[7] $RecordType=(($_ -split "]")[1] -split " ")[1] $Query=($_.ToString().Substring(110)) -replace "\s" -replace "\(\d?\d\)","." -replace "^\." -replace "\.$" $Result=(((($_ -split "\[")[1]).ToString().Substring(9)) -split "]")[0] -replace " " } $DateTime=Get-Date("$Date $Time") -Format "yyyy-MM-dd HH:mm:ss" if ($_ -match $TheReverseRegExString) { $QueryType="Reverse" } else { $QueryType="Forward" } $returnObj = New-Object System.Object $returnObj | Add-Member -Type NoteProperty -Name Date -Value $DateTime $returnObj | Add-Member -Type NoteProperty -Name QueryType -Value $QueryType $returnObj | Add-Member -Type NoteProperty -Name Client -Value $Client $returnObj | Add-Member -Type NoteProperty -Name SendReceive -Value $SendReceive $returnObj | Add-Member -Type NoteProperty -Name Protocol -Value $Protocol $returnObj | Add-Member -Type NoteProperty -Name RecordType -Value $RecordType $returnObj | Add-Member -Type NoteProperty -Name Query -Value $Query $returnObj | Add-Member -Type NoteProperty -Name Results -Value $Result if ($returnObj.Query -ne $null) { Write-Output $returnObj } } } } END { } } function ReturnDNSLogLines { param( $DNSLog) $PathCorrect=try { Test-Path $DNSLog -ErrorAction Stop } catch { $false } if ($DNSLog -match "^\d\d" -AND $DNSLog -notlike "*EVENT*" -AND $PathCorrect -ne $true) { $DNSLog } elseif ($PathCorrect -eq $true) { Get-Content $DNSLog | % { $_ } } }