Simple bash script that will update your A record to your current IP.
This script can be used in Synology Task Scheduler.
-
To get your Cloudflare Zone ID and API key, log in to the Cloudflare Dashboard for the domain you want to use. Your Zone ID will be displayed in the bottom right corner.
-
To get your API Key, create an API Token with
Zone:Zone:Read
andZone:DNS:Edit
permissions for all zones in your account. Cloudflare API Tokens Guide -
To get your Record ID, run this command line after getting both Zone ID and API key:
curl -s -X GET "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/dns_records?name=example.com" -H "Authorization:Bearer YOUR_API_KEY" -H "Content-Type: application/json"
Cloudflare will return a string that begins with {"result":[{"id":"abcdefg12345"
, - the string in quotes after “id’: is your record ID.
- Store the 3 items into the bash script.
- Go to Synology Control Panel > Task Scheduler
- Create new > Scheduled Task > User-defined Script
- Provide a name to your task as Cloudflare, select user as root
- At the Schedule tab, set as Daily, and set Time to run every 10min (or to your preference).
(Dont forget to select end time at 23:50)
- Go to Task settings tab, and paste the bash script at the Run Command.
- Press OK to save. Enter your Synology password to continue.
- You may run the script for the first time.