Created
April 5, 2024 01:39
-
-
Save simeononsecurity/43fc52be24b11082d2a203c15a2c4cc4 to your computer and use it in GitHub Desktop.
Test Domain Name Resolution against Popular DNS Servers
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
# Define the list of domains to test | |
$domains = @("google.com", "simeononsecurity.com", "github.com") | |
# Define a list of public DNS servers, including those with ad and tracker blocking, and major ISPs | |
$dnsServers = @{ | |
"Google" = @("8.8.8.8", "8.8.4.4") | |
"Control D" = @("76.76.2.0", "76.76.10.0") | |
"Quad9" = @("9.9.9.9", "149.112.112.112") | |
"OpenDNS Home" = @("208.67.222.222", "208.67.220.220") | |
"Cloudflare" = @("1.1.1.1", "1.0.0.1") | |
"AdGuard DNS" = @("94.140.14.14", "94.140.15.15") | |
"CleanBrowsing" = @("185.228.168.9", "185.228.169.9") | |
"Alternate DNS" = @("76.76.19.19", "76.223.122.150") | |
"NextDNS" = @("45.90.28.69", "45.90.30.69") | |
"AT&T DNS" = @("68.94.156.1", "68.94.157.1") | |
"Comcast Xfinity DNS" = @("75.75.75.75", "75.75.76.76") | |
"Spectrum DNS" = @("71.10.216.1", "71.10.216.2") | |
"CenturyLink DNS (Dynamic IP)" = @("205.171.3.66", "205.171.202.166") | |
"CenturyLink DNS (Static IP)" = @("205.171.3.26", "205.171.2.26") | |
"Charter Communications DNS" = @("24.196.64.53", "71.10.216.1") | |
} | |
# Loop through each DNS server pair | |
foreach ($server in $dnsServers.GetEnumerator()) { | |
foreach ($dns in $server.Value) { | |
Write-Output "Testing DNS server: $($server.Key) with IP: $dns" | |
# Loop through each domain | |
foreach ($domain in $domains) { | |
try { | |
# Perform the DNS query using the specified server | |
$query = Resolve-DnsName -Name $domain -Server $dns -ErrorAction Stop | |
# If successful, print the IP address(es) resolved | |
$query | ForEach-Object { | |
Write-Output "`t$($domain) resolves to: $($_.IPAddress)" | |
} | |
} catch { | |
# If the query fails, print the error message | |
Write-Output "`tFailed to resolve $($domain) using ${dns}: $_" | |
} | |
} | |
Write-Output "--------------------------------------" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment