Dynamic Domain Name System (DDNS) is used to provide human-readable domain names for networks that have dynamic IP addresses. Most home networks and quite a few business networks do not have static IP addresses on their Wide Area Network (WAN). It is much easier to remember host.domain.com than it is some random IP address that may change on a semi-regular basis.
You certainly could. Some are free, while others charge a monthly or yearly fee. Many residential grade routers can tie into a DDNS service. I have been using GoDaddy for domain registration for quite a few years, and I have been happy with their service. They already provide DNS for the domains I own, AND they let me programmatically control the DNS entries. I already have everything I need, why tie into another service?
You only need two things - a domain registered with GoDaddy and a Linux based computer. Don't let that second one scare you; you know that Windows 7 PC that you still have? It will run Linux just fine! A Raspberry Pi is also a good choice, it is cheap and will let you dip your toe in Linux with LOTS of support on the Interwebs!
After you have an account with GoDaddy, you can log into the developer portal and follow the steps to get your Application Program Interface (API) key and secret (password). Document them; you will need them in a few minutes. The next step is to make sure your computer has the pre-requisites. Open a terminal and install git, curl, and ssmtp:
sudo apt update && sudo apt install git curl ssmtp -y
Now we should create a directory and clone a repository from GitHub - you can manually download the needed files here, but what fun is that?
sudo mkdir /usr/local/bin/git
sudo git clone https://github.com/dr-b-io/GoDaddyDNS.git
Once we have the repository we need to rename one file and make a few edits to it:
sudo mv GoDaddyDNS/GoDaddyDNS.config.dist GoDaddyDNS/GoDaddyDNS.config
sudo nano GoDaddyDNS/GoDaddyDNS.config
When the file opens in the editor there are a few things we need to update:
When you are done updating those settings, save the file by pressing CRTL+O. We need to make the script executable and run the script as root for the first time:
sudo chmod +x GoDaddyDNS/GoDaddyDNS.shl
You should see a few lines of output that show your external IP address and notification that GoDaddy has been updated. You can log into the GoDaddy console to verify the DNS entries have been updated. Now, let's automate the process so GoDaddy gets your new IP address any time it changes. We should still be logged in as root, so we don't need the sudo commands for the next few steps.
Add the following two lines
Save and close the file (CTRL+O and CTRL+X). Lastly, make it executable.
chmod +x /etc/cron.hourly/GoDaddyDNS
That is it; the script should run automatically every hour and GoDaddy will have a human-readable DNS entry for you to get back into your network!
Just about any computer from the last ten years or so should work fine, but if you don't have one Raspberry Pi's are pretty cheap and fun! The image came from Unsplash - it didn't have anything to do with this topic, but I liked it. Of course, GoDaddy was used as the domain registrar and DNS service.