DNS Resolution Checking Script
This script is meant to be used once you have delegated your nameservers to the ones you control. It will take a while to have it delegated so this small script is to help you check if the resolution is successful. The output of the script will produce exit codes following the commands executed. At the end of successful run of the command, it will create a file with the domain name.
#!/bin/sh
domain="<INSERT_YOUR_FQDN"
aname_resolve=$(/usr/bin/host $domain| awk 'NR==2{print $5}')
dns_refused="5(REFUSED)"
resolve_success=$(/usr/bin/touch /root/$domain)
while [ "$aname_resolve" = $dns_refused ]
do
echo 'fail'
exit 1
if [ $? -eq 0 ]
then
$resolve_success
fi
echo 'script failed'
done
Add a cronjob
and you’re good to go.
Feel free to modify.
For more information visit this link
Written with StackEdit.