Update check-dns-server.ps1

This commit is contained in:
Markus Fleschutz 2023-02-15 11:02:53 +01:00
parent 5f4d05f349
commit 73cdf18b94

View File

@ -2,7 +2,7 @@
.SYNOPSIS .SYNOPSIS
Check DNS servers Check DNS servers
.DESCRIPTION .DESCRIPTION
This PowerShell script checks the speed of public DNS server. This PowerShell script measures the availability and latency of public DNS servers and lists it.
.EXAMPLE .EXAMPLE
PS> ./check-dns-server PS> ./check-dns-server
.LINK .LINK
@ -11,26 +11,25 @@
Author: Markus Fleschutz | License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
function CheckDNS { param($Name, $PriIPv4, $SecIPv4) function CheckDNS { param($Name, $IPv4Pri, $IPv4Sec)
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
$null = (nslookup fleschutz.de $PriIPv4 2>$null) $null = (nslookup fleschutz.de $IPv4Pri 2>$null)
[int]$Elapsed1 = $StopWatch.Elapsed.TotalMilliseconds [int]$Elapsed1 = $StopWatch.Elapsed.TotalMilliseconds
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
$null = (nslookup fleschutz.de $SecIPv4 2>$null) $null = (nslookup fleschutz.de $IPv4Sec 2>$null)
[int]$Elapsed2 = $StopWatch.Elapsed.TotalMilliseconds [int]$Elapsed2 = $StopWatch.Elapsed.TotalMilliseconds
" `"$Name`"; `"$PriIPv4`"; `"$SecIPv4`"; `"$Elapsed1 ms / $Elapsed2 ms`"; " New-Object PSObject -Property @{ DNS_server=$Name; IPv4="$IPv4Pri / $IPv4Sec"; Latency="$Elapsed1 / $Elapsed2 ms" }
} }
try { function ListDNSServerSpeed {
Write-Progress "Measuring speed of public DNS servers..." Write-Progress "Measuring latency of public DNS servers..."
" `"DNS SERVER`"; `"PRIMARY IPv4`"; `"SECONDARY IPv4`"; `"LATENCY`"; "
CheckDNS "Cloudflare (standard)" 1.1.1.1 1.0.0.1 CheckDNS "Cloudflare (standard)" 1.1.1.1 1.0.0.1
CheckDNS "Cloudflare (with malware blocklist)" 1.1.1.2 1.0.0.2 CheckDNS "Cloudflare (with malware blocklist)" 1.1.1.2 1.0.0.2
CheckDNS "Cloudflare (with malware+adult blocklist)" 1.1.1.3 1.0.0.3 CheckDNS "Cloudflare (with malware+adult blocklist)" 1.1.1.3 1.0.0.3
CheckDNS "DNS0.eu (standard)" 193.110.81.0 185.253.5.0 CheckDNS "DNS0.eu (standard)" 193.110.81.0 185.253.5.0
CheckDNS "DNS0.eu (kids)" 193.110.81.1 185.253.5.1 CheckDNS "DNS0.eu (for kids)" 193.110.81.1 185.253.5.1
CheckDNS "DNS0.eu (zero)" 193.110.81.9 185.253.5.9 CheckDNS "DNS0.eu (zero)" 193.110.81.9 185.253.5.9
CheckDNS "Google Public DNS" 8.8.8.8 8.8.4.4 CheckDNS "Google Public DNS" 8.8.8.8 8.8.4.4
CheckDNS "Level3 one" 4.2.2.1 4.2.2.1 CheckDNS "Level3 one" 4.2.2.1 4.2.2.1
@ -47,6 +46,11 @@ try {
CheckDNS "Quad9 (with malware blocklist, with DNSSEC, with EDNS)" 9.9.9.11 9.9.9.11 CheckDNS "Quad9 (with malware blocklist, with DNSSEC, with EDNS)" 9.9.9.11 9.9.9.11
CheckDNS "Quad9 (with malware blocklist, with DNSSEC, NXDOMAIN only)" 9.9.9.12 9.9.9.12 CheckDNS "Quad9 (with malware blocklist, with DNSSEC, NXDOMAIN only)" 9.9.9.12 9.9.9.12
CheckDNS "Verisign Public DNS" 64.6.64.6 64.6.65.6 CheckDNS "Verisign Public DNS" 64.6.64.6 64.6.65.6
Write-Progress -completed " "
}
try {
ListDNSServerSpeed | Format-Table -property @{e='DNS_server';width=50},@{e='IPv4';width=32},@{e='Latency';width=15}
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"