Update Cloudflare as DDNS

Hi, I search a lot on many forum but I find a complete tutorial for it.
I’m a beginner and I host a little website on my raspberry pi but my operator provide a dynamic ip so I need to update it on cloudflare.
I look somes tutorials which update with a bash script but I think this method is out of date.
So can you explain me clearly, step by step how to implement this ?
Sorry also for my bad english.
Ty for your help.

Hi @barbehugo28,

I’m not a programmer, so I won’t be able to guide you step by step, but I found this article in the Support Center and I’m sharing it in an attempt to help you:

It was updated today! :slight_smile: Please tell us if you have succeeded in implementing it.

1 Like

This is the script I use on my Raspberry PI. Just change the CAPITALIZED fields.

#!/bin/bash
ipadr=`ip -4 addr show eth0 | grep inet | awk '{print $2}' | awk -F "/" '{print $1}'`
curl -X PUT "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records/RECORD_ID" \
     -H "X-Auth-Email: EMAIL" \
     -H "X-Auth-Key: API_KEY" \
     -H "Content-Type: application/json" \
     --data '{"type":"A","name":"SUB.EXAMPLE.COM","content":"'${ipadr}'","ttl":1,"proxied":false}'
echo ""
1 Like

I’ve allready look at some code like this, where I need to place this code ? In a .sh file ? Ty for your answer !

It’s a script (pidns.sh) that I run every couple of hours via cron.

Okay, thanks !
Do you have a tutorial or something like, to make some script like this with cron ?

stackoverflow is a good resource for coding assistance.

1 Like

Ok thanks, just one last little question, where can I find a the zone id and the record id ?
And for the api key, I need to take my global api key ?

Zone ID is in the Overview tab for that domain in the Cloudflare Dashboard. Once you have the Zone ID, you can query the API for a DNS listing that includes Record IDs.

https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.