Hello all,
I tried in vain to get ddclient or inadyn installed and working to update my Google Domains DDNS but I kept hitting a dead end with weird errors. I decided to write a script (my first!) instead. I admit I copied some things from other people .. even some people on this forum, to get this done. The scripts I had seen did not do a check to see if the IP had changed, so as to not send excessive updates I added a check.
At first I was going to use a DHCPC-EVENT script but for some reason it was executing twice at boot. I decided to schedule it in crontab every hour (@hourly ./gdns) instead, as that should sufficient for my needs. I just named it gdns and placed in the /jffs/scripts directory.
I still use dnsomatic and changeip.com to maintain a second DDNS.. just in case, but I think this will work well for updating Google Domains.
For info on using Google Domains DDNS check here: https://support.google.com/domains/answer/6147083?hl=en
I apologize in advance for the script formatting.. I have very little idea what I'm doing as this is all new to me.
Edit: I'm not sure if curl is installed by default? Obviously if it isn't I did install it..
Edit 2: Ok, didn't realize crontab is lost with a reboot. I added "/usr/sbin/cru a GDNS "0 * * * * /jffs/scripts/gdns" to services-start script
I tried in vain to get ddclient or inadyn installed and working to update my Google Domains DDNS but I kept hitting a dead end with weird errors. I decided to write a script (my first!) instead. I admit I copied some things from other people .. even some people on this forum, to get this done. The scripts I had seen did not do a check to see if the IP had changed, so as to not send excessive updates I added a check.
At first I was going to use a DHCPC-EVENT script but for some reason it was executing twice at boot. I decided to schedule it in crontab every hour (@hourly ./gdns) instead, as that should sufficient for my needs. I just named it gdns and placed in the /jffs/scripts directory.
I still use dnsomatic and changeip.com to maintain a second DDNS.. just in case, but I think this will work well for updating Google Domains.
For info on using Google Domains DDNS check here: https://support.google.com/domains/answer/6147083?hl=en
I apologize in advance for the script formatting.. I have very little idea what I'm doing as this is all new to me.
Code:
#!/bin/sh
MyGDomain=yourdomain.com
Username=user generated by Google
Password=pw generated by Google
CurrWANIP=$(nvram get wan0_ipaddr)
if grep -q $CurrWANIP "/jffs/scripts/gdnsip.txt";
then
logger "Google Domains DDNS: WAN IP unchanged, no update necessary"
else
echo $CurrWANIP > /jffs/scripts/gdnsip.txt
logger "Google Domains DDNS: Update in 60 seconds"
sleep 60s
curl -s https://$username:$password@domains.google.com/nic/update?hostname=$MyGDomain&myip=$CurrWANIP
logger "Google Domains DDNS: WAN IP update sent"
fi
Edit: I'm not sure if curl is installed by default? Obviously if it isn't I did install it..
Edit 2: Ok, didn't realize crontab is lost with a reboot. I added "/usr/sbin/cru a GDNS "0 * * * * /jffs/scripts/gdns" to services-start script
Last edited: