Last active
May 21, 2024 07:51
-
-
Save nathan815/b584dda77fda9929089d393f88623746 to your computer and use it in GitHub Desktop.
Mikrotik Router Cloudflare DDNS Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: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