godaddy-dynamic-dns
This is a Node.js script that can be used as "personal dynamic DNS" for domains hosted at GoDaddy. It detects the public IP address of the machine where this script is run on, and updates the DNS A record using GoDaddy's public API. The update only occurs if the public IP address differs from the current DNS A record.
How It Works
- The script calls api.ipify.org to determine the public IP address of your request.
- It then calls GoDaddy API to check your host's current DNS records.
- If the IPs are different, it calls GoDaddy API to update your hosts' DNS record to match your current public IP address.
Installation and Execution
The script has been tested using Node 6.x, though any version that supports ES6 should work. It needs to be run on a machine that is behind the public IP address you want to update your DNS record to.
-
Install Node.js
-
Clone this repository to a local directory.
-
Request Production GoDaddy API Key and Secret for your account from GoDaddy Developer Portal
-
Create
auth.json
file in the root local repository directory, containing the following (consult auth.json.sample):{ "key": "[your GoDaddy API Key]", "secret": "[your GoDaddy API Secret]", "domain": "[your domain name, ex: foo.com]", "host": ["your host(s)", ex: ["www"] or ["www", "api"]] }
-
Run
npm install
in the root local repository. -
Execute this script via
npm start
, ornode ./src/index.js
. -
Repeat the execution periodically, using cron job or other task schedulers.
Notes and Disclaimer
- Feedback, bug report, PR are welcome!
- The script is provided as-is, I hold absolutely no responsibility for any problem with your host records using this script :)))
Docker Installation and Execution
-
Install Docker
-
Clone this repository to a local directory.
-
Request Production GoDaddy API Key and Secret for your account from GoDaddy Developer Portal
-
Create
auth.json
file in the root local repository directory, containing the following (consult auth.json.sample):{ "key": "[your GoDaddy API Key]", "secret": "[your GoDaddy API Secret]", "domain": "[your domain name, ex: foo.com]", "host": ["your host(s)", ex: ["www"] or ["www", "api"]] }
-
Run Docker build:
docker build . -t=godaddy-dynamic-dns
-
Start Docker container:
docker run -d --restart=always -e INTERVAL=3600 --name=godaddy-dynamic-dns godaddy-dynamic-dns
The default check interval is 1 hour (3600 seconds). Modify INTERVAL environment variable if you desire a different interval time.
-
Stop Docker container:
docker stop godaddy-dynamic-dns
-
Restart Docker container, ie: after a host reboot:
docker start godaddy-dynamic-dns
-
Remove Docker container:
docker rm -f godaddy-dynamic-dns