Skip to content

Instantly share code, notes, and snippets.

@nathan815
Last active May 21, 2024 07:51
Show Gist options
  • Save nathan815/b584dda77fda9929089d393f88623746 to your computer and use it in GitHub Desktop.
Save nathan815/b584dda77fda9929089d393f88623746 to your computer and use it in GitHub Desktop.
Mikrotik Router Cloudflare DDNS Script
:global cfu do={\
:local cfzoneid "<zone ID>";\
:local cfrecordid "<zone record ID>";\
:local cfdomain "<A record name>";\
:local cftoken "<cloudflare API token>";\
:local cfip [/ip cloud get public-address];\
:local cfproxied true;\
:local date [/system clock get date];\
:local time [/system clock get time];\
:local cfcomment "Updated by Mikrotik Cloudflare DDNS Script at $date $time";\
:local cfapiurl "https://api.cloudflare.com/client/v4/zones/$cfzoneid/dns_records/$cfrecordid";\
:put "$cfapiurl";\
/tool fetch mode=https\
http-method=put\
url="$cfapiurl"\
http-header-field="content-type:application/json,Authorization:Bearer $cftoken"\
http-data="{\"type\":\"A\",\"name\":\"$cfdomain\",\"content\":\"$cfip\",\"proxied\":$cfproxied,\"comment\":\"$cfcomment\"}"\
output=none\
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment