cf-dns-updater
Update a DNS record on CloudFlare with a new IP.
Want home.yourdomain.com
to point to your home IP?
This little CLI (and node module) lets you do that easily.
Installation
npm install -g cf-dns-updater
npm install --save cf-dns-updater
CLI usage
$ cf-dns-updater --help
Update a DNS record on CloudFlare with a new IP
Usage
$ cf-dns-updater --zone <zoneId> --record <recordId> --api-token <apiToken>
Options
--ip <someIp> IP to update record with. Defaults to current external IP.
--zone <zoneId> Zone ID the record belongs to
--record <recordId> DNS record ID to update
--api-token <apiToken> API token used for authentication
--email <email> Email used for authentication (also requires `--api-key`)
--api-key <apiKey> API key used for authentication (also requires `--email`)
--list Prints the zones and dns records available for the API key
Examples
# Update a record with a specific IP address
$ cf-dns-updater --zone zoneId --record recordId --ip newIp --api-token myApiToken
# Update a record with your current external IP
$ cf-dns-updater --zone zoneId --record recordId --api-token myApiToken
# List records your API key has access to edit
$ cf-dns-updater --list --api-token myApiToken
Environment variables (fallbacks for missing flags)
--zone = CF_ZONE_ID
--record = CF_DNS_RECORD_ID
--api-token = CF_API_TOKEN
--email = CF_AUTH_EMAIL
--api-key = CF_API_KEY
Node usage
Requires Node 18 or above.
import {update, list} from 'cf-dns-updater'
update({
ip: '193.212.1.10',
email: 'you@domain.com',
apiKey: 'yourCFApiKey',
zone: 'cloudFlareZoneId',
record: 'cloudFlareRecordId',
}).then((newRecord) => {
console.log('New record:', newRecord)
})
Docker usage
The ghcr.io/rexxars/cf-dns-updater:latest
Docker image can be used to update a DNS record. In this case, you'll want to use environment variables to configure the tool:
docker run \
-e CF_ZONE_ID=yourZoneId \
-e CF_DNS_RECORD_ID=yourRecordId \
-e CF_API_TOKEN=yourApiToken \
ghcr.io/rexxars/cf-dns-updater:latest
License
MIT © Espen Hovlandsdal