NodeJS Script for updating CloudFlare DNS record of servers with dynamic IP.
- axios
- public-ip
$ git clone git@github.com:chihimng/cloudflare-dns-updater.git
$ cd cloudflare-dns-updater
$ npm install
Fill in your hostname and api key in config.json
Generate an api key at API Tokens Page, select Zone DNS Edit permission
{
"hostname": "homelab.example.com",
"bearerToken": "..."
}
In legacy versions we used the global api key to authenticate with Cloudflare API, see the legacy sample here
$ node index.js
You may use crontab to schedule updates: (every 15 minutes in sample below)
*/15 * * * * /usr/local/bin/node /path/to/repo/index.js