Idiots guide to updating wan ip via api when it changed

Hi all, appreciate this is probably a basic question but I’d love an idiots guide to updating my ip via the api whenever it changes. I’ve tried following the documentation but keep getting a false return. Could I have some assistance please?

This is a script I use on a Raspberry Pi. You’ll need to change the UPPER CASE bits. You’ll need to fish for the RECORD_ID from a different API query.

#!/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 protected]" \
     -H "X-Auth-Key: API_KEY" \
     -H "Content-Type: application/json" \
     --data '{"type":"A","name":"SUB.EXAMPLE.com","content":"'${ipadr}'","ttl":1,"proxied":false}'

Thanks for this, will give it a go later!

1 Like

Sorry I’m struggling to fish for my RECORD_ID? I follow the link you posted but the API query doesnt seem to relate to RECORD_ID?