I have a script that looks up specific records for a domain.
Ie. domain Cpanel.domain; ftp.domain; mail.domain; mx record and txt records. When a specific record is not found the script stops but does not fail or end until it is manually cancelled.
echo "==[ DNS Check ]=="
echo "Google 8.8.8.8 : $(dig @8.8.8.8 $dom +short)"
echo "Cloudflare 1.1.1.1 : $(dig @1.1.1.1 $dom +short)"
echo "Quad 9 9.9.9.9 : $(dig @9.9.9.9 $dom +short)"
echo "Afrihost ns.dns1.co.za : $(dig @ns.dns1.co.za $dom +short)"
#echo "Afrihost 169.1.1.1 : $(dig @169.1.1.1 $dom +short)"
echo "-- -- -- -- -- -- -- -- -- -- -- -- "
echo
echo "==[ PUBLIC ]=="
getIP=$(dig @8.8.8.8 +short $dom)
if [[ "$getIP" == "" ]];then
echo "Domain NSLookup failed!! - Public DNS Resolution failed."
else
echo "IP : $getIP :: $(nslookup $getIP |grep "name =" |awk '{print $4}')"
echo "cPanel : $(dig @8.8.8.8 +short cpanel.$dom) -- $(nslookup $(dig @8.8.8.8 +short cpanel.$dom) |grep "name =" |awk '{print $4}')"
echo "FTP : $(dig @8.8.8.8 +short ftp.$dom) -- $(nslookup $(dig @8.8.8.8 +short ftp.$dom) |grep "name =" |awk '{print $4}')"
echo "mail.$dom : $(dig @8.8.8.8 +short mail.$dom) -- $(nslookup $(dig @8.8.8.8 +short mail.$dom) |grep "name =" |awk '{print $4}')"
fi
Output:
./resolve somedomain
Date : 17/10/2019 Time : 07.21.11
==[ DNS Check ]==
Google 8.8.8.8 : 103.9.170.0
Cloudflare 1.1.1.1 : 103.9.170.0
Quad 9 9.9.9.9 : 103.9.170.0
Afrihost ns.dns1.co.za :
-- -- -- -- -- -- -- -- -- -- -- --
==[ PUBLIC ]==
IP : 103.9.170.0 :: hostingservername.
>
I would like it to not stop but move on or just indicate record not found and then go to the next command.
At the ">" would be the cpanel.domain A record, which does not exist for the domain in question.
What I would like it to do is print "not found" and then continue to the next command.