Indoor waterfall from below.

DDNS Using GoDaddy

BrianSnelgrove - February 9, 2020
Posted Under: Scripting
If you have hosting service or domain name registration through GoDaddy, you can use it in place of an external Dynamic DNS service. Similar processes can be used for other vendors, but GoDaddy is used in this example.

 

Unless otherwise noted, all directions are for Debian based systems. Most steps will work for other distributions but some commands may need modifications.
Dynamic what?

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.

Why don't I just use a DDNS service?

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?

What do you need to get started?

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!

Let's jump in!

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
cd /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:

  • DOMAIN="EXAMPLE.COM" - this should be the domain you purchased through GoDaddy
  • DNS="HOSTNAME" - this should be the hostname you want to use - vpn.example.com, home.example.com, etc.
  • KEY="GODADDY_KEY" - this is the API key you got from GoDaddy
  • SECRET="GODADDY_SECRET" - this is the API secret you got from GoDaddy
  • EMAIL="EMAILADDRESS" - this is your email address for notifications if the process fails
  • EMAILPASSWORD="EMAILPASSWORD" - this is your email password so the process can send messages
  • MAILHUB="EMAIL.SERVER:PORT" - this is the mail server, for example, gmail is smtp.gmail.com:465

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
sudo -i
/usr/local/bin/git/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.

nano /etc/cron.hourly/GoDaddyDNS

Add the following two lines

#!/bin/bash
/usr/local/bin/git/GoDaddyDNS/GoDaddyDNS.shl

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!

Resources for this tutorial:

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. 



Discussion - all postings are moderated