Bromania Wiki

Scribblings of a Brit in Romania

User Tools

Site Tools


tech:unix:freebsd:godaddydynamicdns

Configuring Dynamic DNS Updates for GoDaddy

Environment

  • FreeBSD 13.1
  • Dynamic IP address
  • Domain from GoDaddy

Required Ports

  • ftp/curl
  • shells/bash

Overview

Since around March 2024, GoDaddy have blocked their API to all users who have less than 50 domains registered with them. I recommend you use Cloudflare's free DNS with dns/ddclient, and move your registrar before your domain is next up for renewal.

Most home users have a dynamic IP address provided by their ISP. If they want to host their own services, such as a web server, this poses a problem as if their IP changes, their domain no longer points to the correct address.

This article explains how to set up a cronjob which periodically calls a script to update a domain's DNS record if the server's external IP has changed.

Installation

If you do not already have ftp/curl and shells/bash installed then install them from packages, or build it from the ports collection.

Now download updatedomain.sh, and copy it to /usr/local/bin. It is a bash version of this PowerShell script, which has been modified several times. The script is believed to be in the public domain.

Set the permissions on the script so only the owner can read and execute it:

# chmod 700 /usr/local/bin/updatedomain.sh

Configuration

GoDaddy API Key and Secret

Firstly you will need a GoDaddy API key and secret from here for the Production environment. Make sure you keep it safe as it can be used to manipulate your domain.

Edit Script Variables

Now edit /usr/local/bin/updatedomain.sh, and fill in the key and secret values that you got from GoDaddy.

key=""      # key for godaddy developer API
secret=""   # secret for godaddy developer API

If you intend to run the script as a user other than root then change the ownership to that user:

# chown nobody /usr/local/bin/updatedomain.sh

Add cronjob

Now edit the crontab for the user who will run the script. If it is root then simply run:

# crontab -e

Otherwise specify the name of the user:

# crontab -u nobody -e

If you want your domain, and all subdomains, to be updated when your IP changes, add the following line to your crontab:

*/5    *       *       *       *       /usr/local/bin/updatedomain.sh @ yourdomain.ro >> /var/log/updatedomain.log

If you only want one of your subdomains to be updated then add this one:

*/5    *       *       *       *       /usr/local/bin/updatedomain.sh subdomain yourdomain.ro >> /var/log/updatedomain.log

The script is set to run every 5 minutes. You can, of course, change this if you like. Note that the location for the log file, /var/log/updatedomain.log in this example, must be writable by the user running the script, or any domain updates will not be logged. Once you have confirmed that the script is working for you, you can replace /var/log/updatedomain.log with /dev/null to suppress the output of the script altogether.

DNS Record TTLs

I recommend you go to GoDaddy DNS Management, and change your domain and any subdomains' TTL setting from 1 Hour to 1200 seconds (20 minutes). This means that your new IP will be propagated in a maximum of 20 minutes. You could reduce this value further, but performance may be affected.

References

tech/unix/freebsd/godaddydynamicdns.txt · Last modified: 2024/05/21 15:45 by puisor