Script to update DomainGoogle

Being on a home network with a dynamic IP I have to constantly monitor my IP for if and when it changes. There is a Ddns program to install but I choose to write my one shell script to update to Google every hour by using a crontab I’m not a programming guru but I can learn my example. I looked at many YouTube videos and got the idea. But there is one thing I leaned is there are many videos outdated or just plain wrong. I patched together a script that worked without causing an error. The first time after I installed “sendMail” for WordPress notifications I got spammed with error emails from crontab. The URL to Google Domains was not up to the latest standards with the user and password inline with the address. I learned to shut off the email alerts but I just had to fix the problem.

The problem was wget and using That apparently not a legitimate url. By using the wget switch --user=(usename) --password=(password) stopped the error message. I added a additional part of my code to make sure the internet was present. as not to have the script cause a freeze.

wget --user=(username) --password=(password)  -O dns_update_results.txt

#!/bin/bash -e 
if [[ "$(ping -c 1 | grep '100% packet loss' )" != "" ]]; then
echo "Internet isn't present $(date)" >>
exit 1
echo "Internet is present $(date)" >>
wget --user=(usename) --password=(password) -O dns_update_results.txt
echo " Last run $(date)" >> dns_update_results.txt
cat dns_update_results.txt >>
rm -f
cat -n >>


I hope this is useful to someone. There seems to be an exploit with the dns updater app so it makes sense to use this script. Thanks for your time. I’m sorry this blog isn’t in Mandarin with all the hits from China 😁