Last active
February 23, 2021 03:23
-
-
Save linuxwizard/289e547130a849f2077759ba4393d657 to your computer and use it in GitHub Desktop.
Bulk Bash DNS checker
This file contains hidden or 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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running it as "sh dns_check.sh" may not work due to array usage. use ./dns_check.sh instead if not working.