This is a simple script that will fix your dns record for your hostname in cloudflare, using the cloudflare api.
List of required environment variables:
API_TOKEN
- Your cloudflare api keyZONE_ID
- The zone id of the domain you want to updateRECORD_ID
- The record id of the record you want to updateHOST_NAME
- The name of the record you want to updatePROXIED
(optional) - If the record should be proxied or not (true/false) (default: true)
run:
API_TOKEN=123 ZONE_ID=123 RECORD_ID=123 HOST_NAME=example.com ./hostfix.sh
Check our example folder for a Kubernetes CronJob example. Once the container is executed with the required environment variables, it will update the record with the current public ip address.
- The zone id can be found in cloudflare dashboard, in overview of the domain.
- The record id can be found in cloudflare api using the following url API Documentation:
https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records
curl -X GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records?page=1&per_page=100&order=type&direction=desc&match=all" \
-H "Authorization: Bearer {api_token}" \
-H "Content-Type: application/json"
You can find the docker images on Docker Hub.
docker pull tmota900/ss-hostname-fixer
docker run -e API_TOKEN=123 -e ZONE_ID=123 -e RECORD_ID=123 -e HOST_NAME=example.com tmota900/ss-hostname-fixer