A Node.js script to programmatically update GoDaddy DNS records
This Node.js script allows you to programmatically update one or more GoDaddy DNS records inserting the public IP of the machine where the script is run.
godaddy-dns -c config.json
This script requires Node.js (version >= 6.0.0) and a valid GoDaddy API key and secret. You can get register a new key on your GoDaddy developer page
To install the script globally you can use NPM:
npm install --global godaddy-dns
If you have the script already installed in your system, this command will update it to the latest available version.
After executing this command the script
godaddy-dns will be globally available
in your system. Give it a try with:
From version 1.1.0, you can also install godaddy-dns by simply downloading the binary executable file for your operative system in the Releases section.
The command needs a configuration file in order to be executed. The configuration
file can be specified at runtime using the option
--config, if not specfied the
command will try to access the file
.godaddy-dns.json in the home directory of
the current user.
The configuration file contains a JSON object with the following fields:
- apiKey: The API key for your GoDaddy account
- secret: The API key secret for your GoDaddy account
- domain: The domain for which to update the DNS records
- records: An array of objects that defines the records to update. Every record object can define the following values:
- name: (mandatory) the name of the record (e.g.
- type: (default
"A") the type of entry for the record
- ttl: (default
600) the TTL of the record in seconds (min value is 600)
You can define the DNS records in the records configuration also using a shorter
syntax by just passing the name of the domain as a plain string (e.g.
If you have a single record wrapping it into an array is optional, you can
simply pass it as a single string or object.
See config.json.sample for an example of how to structure
Update multiple domains
If you need to update multiple domains you can use the option
domain in the records array as in the following configuration example:
In this example, everytime a new IP is detected the following domains will be updated:
Last IP cache
To avoid to send useless requests to the GoDaddy API (e.g. when the IP is not
changed) the script stores the last public ip sent to GoDaddy in a cache file.
This file is by default stored in the default OS temp folder with the name
You can use a custom location for this file with the option
If you want to clear this cache (and force a new request to the GoDaddy API) you
can simply delete this file.
Running the script continuously with Cron
One of the principal use cases why you might want to use this script (and actually my original motivation to create it) is to map a DNS record to a machine with a non-static IP. This way you can recreate your home-made DynamicDNS solution.
In this scenario you might want to add an entry to your Cron configuration as in the following example:
*/5 * * * * godaddy-dns > /var/log/godaddy-dns.log 2>&1
In this case the script will be executed every 5 minutes and the logs will be stored
/var/logs/godaddy-dns.log. Also note that in this example you will use the
default configuration file location. If you want to specify a different location
use the option
Command line options
Usage: godaddy-dns [options] Options: -h, --help output usage information -V, --version output the version number -c, --config [file] specify the configuration file to use (default "<user home folder>/.godaddy-dns.json") -i, --ipfile [file] specify which file to use to store the last found ip (default "<user temp folder>/.lastip")
If you want to use the features of this module in a Node.js project:
const dns = ;dns;
Thanks @aandrulis for suggesting to expose this.
Bugs and improvements
Licensed under MIT License. © Luciano Mammino.