We can use crontab to update our Dynamic DNS. It’s a nice feature and super easy. Who wants a whole application dedicated to telling a remote server your IP?
Create a script, not necessary, can do it right in crontab, but why? make a script. If you don’t have a scripts folder in your home directory make one.
mkdir scripts I’m not here to teach you basic bash commands.
Put the following in the script.
OR, I use this one now, but same concept (the q tells it to be quiet and the O tells it to full output to stdout (so we can kill the downloaded file by writing it to /dev/null in our crontab))
wget --no-check-certificate -qO-
The script needs to be executable.
chmod 755 /home/username/scripts/update-dns.sh
Make sure that your xxxxx.com domain name has a dynamic listing for @ and that the password for updating it is still correct in the script. This is registrar dependent. Ask them how to enable dynamic DNS on their side and get the password.
Set it in to a cron job to run every hou. Crontab keeps track of your users cron jobs. They will run even if you aren’t logged in.
add at the bottom. This will run on the hour every hour. Some people update it every 15 minutes. I don’t. The last part of the call there, the > /dev/null 2>&1 tells the shell to send any output on stdout or stderror to nowhere-land. If you don’t do this, wget will download a file in your home directory called update every hour. You don’t want that, you want to update your IP and ignore that update file. So kill it with that redirect.
0 * * * * /home/username/scripts/update_dns.sh > /dev/null 2>&1