Last active
October 5, 2022 03:11
-
-
Save dtsdwarak/19abfd5d1ae18c4cd929d082b9d207fc to your computer and use it in GitHub Desktop.
CLOUDFLARE DNS UPDATE SCRIPT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################################################### | |
# CLOUDFLARE DNS UPDATE SCRIPT | |
# Documentation : https://api.cloudflare.com/#dns-records-for-a-zone-update-dns-record | |
# Author: @dtsdwarak | |
###################################################################################### | |
#! /bin/bash | |
zone_identifier=kqgsnbdYFSxFEqpzl7vV | |
dns_record_identifier=yMlGtxPWAsVIRv2kKbRe | |
[email protected] | |
cloudflare_auth_key=2ka8HXFpAE0gU05f3s55 | |
hourstamp=$(date +"%F-%H") | |
past_ip=$(cat /home/your-user/scripts/ip.log) | |
publicip=$(curl https://api.ipify.org 2>/dev/null) | |
if [ $past_ip = $publicip ]; then | |
printf "\n$(date) : IP Address of drive.dwarak.in not changed.\n" >> /var/log/cloudflare/dns-drive-dwarak-in-update/$hourstamp.log | |
exit 1 | |
fi | |
echo $publicip>/home/your-user/scripts/ip.log | |
curl -X PUT "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records/$dns_record_identifier" \ | |
-H "X-Auth-Email: $cloudflare_email" \ | |
-H "X-Auth-Key: $cloudflare_auth_key" \ | |
-H "Content-Type: application/json" \ | |
--data '{"type":"A","name":"drive","content":'\"$publicip\"',"ttl":120,"proxied":false}' > /dev/null | |
printf "\n$(date) : Changed IP address of drive.dwarak.in to $publicip \n" >> /var/log/cloudflare/dns-drive-dwarak-in-update/$hourstamp.log |
Log file updates but zone does not. What have I done wrong?
I see the API hasn't changed. Can you please check and see if you are able to make a PUT request to the endpoint with the values hardcoded?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Log file updates but zone does not. What have I done wrong?