This script automatically updates DNS records on DigitalOcean with your current public IP address. It is designed to run continuously, checking for IP changes at a specified interval and updating the records as needed.
- Automatically detects your current public IP address
- Updates specified DNS records on DigitalOcean with the current IP
- Customizable update interval (default: 5 minutes)
- Supports updating multiple domains and records
- Easy setup with environment variables for DigitalOcean API token and update interval
- A DigitalOcean account with API access
- Docker
or
- Node.js (version 12 or higher)
doctl
command-line tool installed and configured with your DigitalOcean API token
docker run \
-e DIGITALOCEAN_TOKEN=<YOUR_TOKEN_HERE> \
-e INTERVAL_SECONDS=300 \
-v /path/to/records.json:/records.json \
ghcr.io/luisegr/dns-autoupdater:latest
-
Clone the repository:
git clone https://github.com/LuisEGR/digitalocean-dns-updater.git
-
Navigate to the project directory:
cd digitalocean-dns-updater
-
Install the dependencies:
npm install
-
Set the required environment variables:
DIGITALOCEAN_TOKEN
: Your DigitalOcean API token. Generate one from the DigitalOcean API settings page.INTERVAL_SECONDS
(optional): The interval in seconds between each IP check and update. Default is 300 seconds (5 minutes).
-
Configure the DNS records to update in the
records.json
file. The file should be in the following format:{ "example.com": [ { "name": "subdomain1", "type": "A", "ttl": 3600 }, { "name": "subdomain2", "type": "A", "ttl": 1800 } ], "example.net": [ { "name": "@", "type": "A", "ttl": 3600 } ] }
To start the DNS updater, run the following command:
npm run start
The script will continuously run, checking your public IP address at the specified interval and updating the configured DNS records on DigitalOcean if necessary.
-
records.json
: This file contains the DNS records to be updated. Each domain is represented as a key, and the value is an array of records. Each record should have aname
,type
, andttl
property. -
DIGITALOCEAN_TOKEN
environment variable: Set this to your DigitalOcean API token. You can generate a token from the DigitalOcean API settings page. -
INTERVAL_SECONDS
environment variable (optional): Set this to the desired interval in seconds between each IP check and update. The default value is 300 seconds (5 minutes).
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.