Monitor DNS resolution and internet connectivity script
while true; do
date
echo "DNS check:"
host google.com
echo "Ping check:"
ping -c 1 google.com | grep "time="
echo "---"
sleep 5
done
See ping for more details on what this is doing.
The host
command contacts a DNS server and does a reverse lookup for the IP-address of the human-readable domain name.