Page 1 of 1

[Tutorial] Update Cloudflare DNS record by script.

Posted: Wed Dec 11, 2024 10:00 am
by root87hk
Today the mikrotik routeros build-in DDNS outage make everyone tons of system outage.
I am planing to switch to update the dns record public ip to cloudflare API by using scheduler script. :D
# get the public ip address
:global getPublicIp [/tool/fetch url=https://api.ipify.org output=user as-value];
:global debugA1 ($getPublicIp->"data");

# set the public ip address
:local zoneId xxxxxxxxxxxxx
:local redordId xxxxxxxxxxxxx
:local authApiToken xxxxxxxxxxxxx
:global updateCloudflareRecord [/tool fetch url="https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records/$redordId" http-method=patch http-header-field="Content-Type: application/json,Authorization: Bearer $authApiToken" http-data="{\"content\":\"$debugA1\"}" output=user as-value];
:global debugB1 ($updateCloudflareRecord->"status")
:global debugB2 ($updateCloudflareRecord->"data")


Re: [Tutorial] Update Cloudflare DNS record by script.

Posted: Wed Dec 11, 2024 1:27 pm
by Larsa
You should add a status check for the update API. There are tons of scripts on GitHub you can check out to see how it’s done: "github mikrotik cloudflare ddns script"

Re: [Tutorial] Update Cloudflare DNS record by script.

Posted: Wed Dec 11, 2024 4:30 pm
by anav
So this is just another dyndns type service, nothing more nothing less? Is it free as well?
Sadly cannot be used to replace BTH LOL