GoDaddy DDNS Updater

As I’m running this site itself on my 4TB WDMyCloud home NAS, refer to my post WebHosting on WDMyCloud V4 Firmwares, I will need my DNS to be always pointing to it when my public IP changes.

Although my public IP seldom changes, I’ve been using a Python based script with its ‘pygodaddy’ module for a while to auto update my GoDaddy DDNS pointing to my WDMyCloud NAS. The script is supposed to update my current public IP by parsing GoDaddys DNS update form. But on few occasions when there’s the need to update, the script failed to work because obviously GoDaddy had changed something in their front-end. I’ve also used a similar PHP based script but that too failed to work. And worst still, for as long that I know of, GoDaddy hasn’t provide any means of updating the records other than manually from their site itself.

Like many others with paid GoDaddy domain account, I’ve been looking for permanent solution not until recently and long awaited for, GoDaddy has finally implemented some APIs for developments which now provides the ability to update the DNS records via a REST call. You can see more details at their developer’s site, https://developer.godaddy.com.

Disclaimer: As I’m frequently updating the original guides and installers here on TeaNazaR.com, I will not be responsible for any brick issues if you were to follow my obsolete guides copied elsewhere. Thus subscribe to this post to get latest updates. Modifying any part of a device may void its warranty.

With this API, I’ve written another simple shell script to perform the DDNS update which can be scheduled with a 5mins repeating Cron job. It should work on any Linux based systems. Why shell script? It’s simple, low-resource and does the update faster than any similar Python, PHP, Perl, Java JIT compiler I’ve tested on the NAS. On each run, the script will check for public IP changes against the local cache and GoDaddy records itself using cURL and only attempt to update if necessary. Even though GoDaddy did not specify the minimum update interval, updating too frequently could affect DNS propagation which could cause delay of the DNS being updated across the internet.

GoDaddy.sh
GoDaddy.sh

First you will need is of course your paid domain name, then a GoDaddy “ProductionAPI key/secret to use with this script. Go to this specific link, log in with your GoDaddy account then generate the API key/secret. Note that the very first time you do this, it will be created as “Test” environment (seen at the time of writing). Go back to the same page again or click on the “Keys” top menu then generate a new “ProductionAPI key/secret instead.

GoDaddy API
GoDaddy API

You can place this script anywhere on your server. I’ll explain more for users who’s not familiar with Linux.

Launch the editor i.e. nano /root/scripts/GoDaddy.sh; . Copy & paste the script source from the bottom of this post into the terminal, update the API key/secret , Domain and other desired options, then CTRL+X to save. Test the script if it’s working:

Once the script is in place, schedule a Cron job every 5mins, crontab -e; , examples below on a single line:

a. No logging (recommended):

b. With logging for debugging purposes (you will need to do your own log housekeeping, try logrorate?):

To update a subdomain (second-level domain i.e. subdomain.domain.com) instead of primary domain (top-level domain i.e. domain.com), set Type=A Type=CNAME (Updated: CNAME by default  can’t point to an IP) and Name=subdomain where subdomain is your subdomain.domain.com as seen in the GoDaddy DNS setup page.

I’ve also added optional advanced variables to include any custom scripts, programs or commands to execute when the IP update occurs or failed. This is so that you can place this script on top of your other applications i.e. those which requires public IP update cached in /tmp/current_ip or those which triggers upon IP changes. Read the script’s comments for more details. For instance, you can use Postfix‘s sendmail to trigger an email notification upon IP update or failures by setting the SuccessExec or FailedExec values. Those who’s using my WebHosting on WDMyCloud V4 Firmwares mods, you can configure its ESMTP to get similar results. For an example to get notified upon successful IP update, set the  SuccessExec value to:

This should be the permanent solution for now until GoDaddy decides to make other changes. Need a Windows based DDNS client updater? Not sure why would anyone leave their PC always awaked, unless it’s a Windows based NAS/server. Perhaps I can help to write a simple Windows executable. But you can always run Cygwin to deploy shell scripts also Ubuntu is already runnable in Windows 10 Insider Preview (at the time of writing). For now, only my NAS running 24/7 needs this. Any questions you can post it here, enjoy (-:

GoDaddy.sh

201 thoughts on “GoDaddy DDNS Updater”

  1. Can this be setup to update multiple domains at the same time, or do I just need multiple scripts each one fore each domain?

  2. This looks great.

    Can you tell how can i use this script for ipv6 ?

  3. This has been running fine on my QNAP for months, but after a firmware update I am getting an error – as attached.
    Can you suggest what might be the issue ?
    Thanks

      1. But if you look at the attachment I did a cURL –version which showed:
        CURL 7.43.0 and LIBCURL 7.43.0
        So I am assuming they are installed.

        1. Seems to be CRLF issue. Try creating a new script file using nano or vi then copy and paste the script content again. Or convert the existing script using dos2unix.

        2. Repeating the “which” command from the script seems to get the right response – as attached – showing the directory as sbin/curl

  4. But the $PATH setting appears to omit this sbin/curl folder – could this be the issue even though the CURL seems to be being found?

    1. Your curl is in /sbin and /sbin is already in your path environment so everything is good except did you take a look at my previous reply minutes ago about CRLF?

      1. Thank you.
        I did create it originally with vi, but obviously got some extra line-ends in there somehow.
        Fixed immediately with dos2unix.

  5. Hello,

    I’ve been using your script for some time now and I really enjoy using it. I’ve made a few simple modifications to it and would like to share it with others.

    1. Hi Donald,

      Thanks for sharing. For me personally I would prefer not to flood the log every 5 minutes if there’s no IP changes. So in crontab I would just null the output and use sendmail if there’s changes to the SuccessExec and FailedExec.

      1. Hello Nazar,

        Where do you see that it says it logs every 5 minutes? I use a scheduled task on my server that runs this script every 1 hour and I personally have had no issues with the logs being flooded. I then use another scheduled task that runs every 30 days that executes this code:

        Unless you are referring to the TTL setting, but I have mine set to 3600 seconds.

        I check my logs once a week to see if there are any failed updates. If so, I re-run my script. Here in Alaska, my ISP does ip changes every few weeks. We are also limited on bandwidth allotment and they over charge by far. 200 GB of data is $300 a month at a download rate of 10mbps and 4 mbps upload.

        If I’m missing the part in the script where it says it logs every 5 minutes, please point me to the area where it is.

        Thanks,

        -Donald

        1. Hi Donald, There’s nothing wrong with your recommendation. Some might find it useful on several circumstances. The every 5 minutes is where I’m referring to the original post, TTL is 600 seconds and cron is every 5 minutes. There’s a reason to this.

          Most ISP will change the IP almost every time when reconnecting hence it’s recommended to lower the TTL and cron frequency for such cases. Even for my case, where my IP stays for many months despite reconnecting, I still lower down the values because if an IP change should occur, it will take too long for DNS servers to propagate it thus extending my server unreachable down time further.

          For me, I have an unlimited 1Gbps symmetrical connection. I also seldom check the logs as I rely mostly on email notifications so most of my logs are either disabled or limited to only warning level and above. So in an event if I do receive an email about my IP changes, I would expect all my apps incoming connection via DDNS to be up within 10 minutes or less. But if metered connection is also a concern, feel free to adjust the values accordingly.

  6. For anyone else having an issue getting multiple subdomains to update but running the script only returns

    “Public IP matches Cached IP recorded. No update required!”

    change the CachedIP from

    “/tmp/current_ip”

    to

    “/tmp/current_ip_subdomain”

    and change subdomain as needed.

  7. Hi, I’ve been using your script on openwrt routers for 4 years, I love your script, I recently migrated my GoDaddy domain to Cloudflare, but I don’t know how to write scripts, can you modify the script? I hope it works on Cloudflare too. Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax