Cloudflare Dynamic IP

Kevin FOO
Sep 23, 2020

--

I previously wrote a story about updating your dynamic IP with NoIP.com . If you own a domain and it is currently using Cloudflare’s domain name servers, you can use its API to update your dynamic IP.

Copy the contents below into “update_ip.sh”

#!/bin/bash
ct='Content-Type: application/json'
email='YOUR_EMAIL_HERE'
api_key='YOUR_GLOBAL_API_KEY_HERE'
zone_id='YOUR_ZONE_ID_HERE'
domain='www1.oofnivek.com'
dns_id=$(curl -X GET "https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records?type=A&name=$domain" -H "X-Auth-Email: $email" -H "X-Auth-Key: $api_key" -H "$json"|jq -r .result[0].id)ip=$(curl checkip.amazonaws.com)curl -X PUT "https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records/$dns_id" -H "X-Auth-Email: $email" -H "X-Auth-Key: $api_key" -H "$ct" \
--data '{"type":"A","name":"'$domain'","content":"'$ip'","ttl":1,"proxied":true}'
Your zone ID is located here
Click [View] to get your API key

< Back to all the stories I had written

--

--

Kevin FOO
Kevin FOO

Written by Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

No responses yet