Cover image for How to update IP address on Cloudflare

How to update IP address on Cloudflare

Hosting your services from home? But ISP is providing Dynamic IP Address?

In my scenario, I’ll be using a Synology’s Task Scheduler and Cloudflare.

  1. You’ll need to get all the details for the following variables

     #Email associated with your Cloudflare account
     EMAIL=""
     #Global API Key
     KEY=""
     #Unique ID provided by Cloudflare
     ZONE_ID=""
    
  2. To get your KEY, go to your Cloudflare Profile > API Tokens and copy your Global API Key

  3. To get your ZONE_ID, go to your domain Overview, on the left panel you’ll see the API Zone ID, copy that.

  4. Put them all together and you get something like this:

     #Email associated with your Cloudflare account
     EMAIL="admin@example.com"
     #Global API Key
     KEY="xxxxxxxx"
     #Unique ID provided by Cloudflare
     ZONE_ID="xxxxxxxx"
     #Record type
     TYPE="A"
     #Domain or Subdomain
     NAME="example.com"
     #Get IP Address
     CONTENT="`curl https://ifconfig.co`"
     #Enable Cloudflare proxy
     PROXIED="true" 
     #In seconds, use 1 for automatic
     TTL="1"
    
     #The Code
     curl -X POST "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/" /
     	-H "X-Auth-Email: $EMAIL" /
     	-H "X-Auth-Key: $KEY" /
     	-H "Content-Type: application/json" /
     	--data '{"type":"'"$TYPE"'","name":"'"$NAME"'","content":"'"$CONTENT"'","proxied":'"$PROXIED"',"ttl":'"$TTL"'}'
    
  5. Create a Task Scheduler and drop this script there.

  6. Buy me a drink on Ko-Fi :)

And that’s how you update Cloudflare with a Dynamic IP Address.


← How to setup Ghost on Synology …
How to self-host WriteFreely … →