- wget for installation
- bash
- crontab
- curl
- Cloudfare API KEY with ZONE-DNS-EDIT Permissions
- DNS Record must be pre created
- Domain and Record ID
To create a CloudFlare API token for your DNS zone go to https://dash.cloudflare.com/profile and follow these steps:
- Go to API TOKENS
- Click Create Token
- Click 'Edit zone DNS' from the templates
- On zone Resources click your zone (your domain)
- And Click 'Continue to Summary'
- Click 'Create Token'
- Copy/Paste your API KEY to 'CLOUDFLARE_API_KEY='
- Go to manage account
- Go to Audit Log
- Click on the logs until you find one with the resource name dnssec.dns_settings
- Copy the resource ID from that log
- Paste the resource ID on 'DOMAIN='
- Go to manage account
- Go to Audit Log
- Click on the logs until you find one with the resource name dns.record
- Copy the resource ID from that log
- Paste the resource ID on 'RECORD='
For starters let's install all the dependencies you can do that using the package manager of your choice in this case we will use apt
sudo apt install wget crontab curl jq
You can place the script at any location manually.
wget https://raw.githubusercontent.com/Lilithbtw/cloudfare-ddns-script/main/cloudflare-dyndns.sh
sudo chmod +x cloudflare-dyndns.sh
sudo nano cloudflare-dyndns.sh
To test if it's working run it (if it runs without errors it's working)
./cloudflare-dyndns.sh
to run this script every 5 minutes
crontab -e
and paste
*/5 * * * * /your-path/cloudflare-dyndns.sh