Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 15394

Scripting • Re: Cloudflare's DDNS

$
0
0
This is the first post on Google when searching for Mikrotik's Cloudflare DDNS solutions, and I got my script's original version here from OP. So adding my version here:
Code:
# Script name (must be same as you called the script):local scriptname "<YOUR_SCRIPT_NAME>":if ([:len [/system script job find script=$scriptname]]>1) do={    log info "Another copy of $scriptname is running.";    :error "Another copy of $scriptname is running.";}log info "Started $scriptname";:local cfi "<YOUR_ZONE_ID>";:local cfr "<YOUR_DNS_ENTRY_ID>";:local ctk "<YOUR_API_TOKEN>";:local cfd "<YOUR_TARGET_DOMAIN>";:local cfa [/ip cloud get public-address];:local cfp false;/tool fetch mode=https\http-method=put\url="https://api.cloudflare.com/client/v4/zones/$cfi/dns_records/$cfr"\http-header-field="content-type:application/json,Authorization:Bearer $ctk"\http-data="{\"type\":\"A\",\"name\":\"$cfd\",\"content\":\"$cfa\",\"proxied\":$cfp}"\output=file\dst-path="$scriptname.txt"
The main change here is that I am using Cloudflare's API token (https://developers.cloudflare.com/funda ... ate-token/) which is safer and more flexible. Plus some minor quality of life changes.

Statistics: Posted by ccl13 — Thu Jan 18, 2024 8:46 pm



Viewing all articles
Browse latest Browse all 15394

Trending Articles