Skip to content

Instantly share code, notes, and snippets.

@linuxwizard
Last active February 23, 2021 03:23
Show Gist options
  • Save linuxwizard/289e547130a849f2077759ba4393d657 to your computer and use it in GitHub Desktop.
Save linuxwizard/289e547130a849f2077759ba4393d657 to your computer and use it in GitHub Desktop.
Bulk Bash DNS checker
#!/bin/bash
domain_list='shortlist.txt'
declare -a resol
resol=('8.8.8.8' '8.8.4.4' '1.1.1.1' '1.0.0.1' '9.9.9.9' '149.112.112.112') #multiple resolvers
for domain in `cat $domain_list`
do
ns_ip=${resol[`shuf -i0-5 -n1`]} #select resolver
registrar_detail=`whois $domain | grep -i "registrar:" | tail -n1 | awk '{print $2 $3}' | tr , " "` #fetch registrar. improvement needed
ip=`dig @$ns_ip +short $domain | tail -n1`; #get IP
if [ ! -n "$ip" ]
then
echo "$domain,$registrar_detail,No DNS,,"; #if no IP, no DNS
else
#assembling all data and also adding NETNAME and NameServers to it
echo "$domain,$registrar_detail,$ip,"`whois $ip | grep -i netname | awk '{print $2}'`","`dig @$ns_ip +short ns $domain`;
fi
done
@linuxwizard
Copy link
Author

Running it as "sh dns_check.sh" may not work due to array usage. use ./dns_check.sh instead if not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment