I want to print out the hostname and CNAME only if DNS status is: "NXDOMAIN" OR "SERVFAIL".
So I wrote below bash script but it does not work, any help is very much appreciated, thank you.
for hstnm in $(cat /path/file.txt)
do
if [[ dig @8.8.8.8 -t A ${hstnm} | grep -q 'NXDOMAIN' ]] -o [[ dig @8.8.8.8 -t CNAME $hstnm +short >/dev/null ]]
then
echo -n -e "\e[92mNXDOMAIN: \e[0m${hstnm} "
echo -n -e "\e[93mCNAME: \e[0m"; dig @8.8.8.8 -t CNAME $hstnm +short
echo
fi
done
Aucun commentaire:
Enregistrer un commentaire