← BACK

gdupdate

Godaddy updater

Python ⭐ 0

Godaddy sub-domain updater

This is a simple tool to update a given DNS hosts file managed by Godaddy.
You can (sort of) think of this as a way to get Dynamic DNS from a domain name
managed by Godaddy. This script can be run manually, from cron, or any other
way a script gets executed on your system.

Requirements

Once Python is installed, the dependencies can be installed via pip:

# For system-wide install
pip install -r requirements.txt

# For local-user install
pip install --user -r requirements.txt

Usage

usage: update.py [-h] config

positional arguments:
  config      The JSON config file to load.

optional arguments:
  -h, --help  show this help message and exit

Configuration file

update.py requires a valid configuration JSON file. There is a sample config
file included in this repository which you can use as a template (be sure to
remove the comments, those aren't valid JSON).

The configuration file needs to have the following fields:

  • domain : This field indicates the base domain you wish to update. Let's say
    I wanted ssh.foobar.net to be the full name for my IP to point to. In that
    case, domain would be foobar.net.
  • sub-domain : This field indicates the sub-domain you wish to update. Again,
    if I wanted ssh.foobar.net to be the full name for my IP to point to, I'd
    have sub-domain be ssh.
  • refresh_time : update.py keeps track of the last time it updated the IP
    and what the last IP was. refresh_time is a field that tells the script to
    update the IP after this duration regardless if the IP has changed or not. The
    field should be another JSON dictionary indicating hours, days, seconds,
    and weeks.
  • ip_url : This is a website which, when accessed, will return the IP
    information for the caller. See below for more information.
  • key : This is the application key from Godaddy's API key tool.
  • secret_key : This is the secret key from Godaddy's API key tool.
Setting the IP from a URL

The ip_url setting in the configuration file detailed above must return a
JSON object containing a field, ip which has the IP address to be used. The
idea here is that the remote site will be able to return the public address of
the system contacting it (which, in turn, can be used to find out the correct
IP for the dynamic DNS to work). Of course, it can return any IP address
and the updater will use it. So, if you wanted, you could use this for
something other than dynamic DNS.

A sample CGI script that can generate such a response can be found
here.

Configuration file after run

After the updater script runs, it will update the config JSON file with two
new entries:

  • last_ip : This is the last IP used to update Godaddy.
  • last_update : This is the last time Godaddy was updated.

These two entries will always be automatically generated by the script, and are
not intended to be manually changed.

FAQ

Will it run under Python 3.x or anything more modern?

My script should be fine to run under Python 3.x. However, godaddypy has
certain 2.7-isms that currently prevent it from running under 3.x.

Can I hit my Godaddy API update limit with this?

Probably. You can run this script as often as you want and set your refresh
time to seconds. Of course, I wouldn't recommend doing that.

Personally, I run mine from cron every 5-15 minutes, and then have a full
refresh every 12 hours or so.