Community discussions

MikroTik App
 
root87hk
just joined
Topic Author
Posts: 3
Joined: Sat Jul 25, 2020 4:06 pm

[Tutorial] Update Cloudflare DNS record by script.

Wed Dec 11, 2024 10:00 am

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")

 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1865
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

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

Wed Dec 11, 2024 1:27 pm

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"
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 23332
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

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

Wed Dec 11, 2024 4:30 pm

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