Created
February 28, 2019 09:25
-
-
Save fuyuanli/b2a586ffd5aefcbf453437e9ce663b48 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# GET Recore ID | |
#curl -x get "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/dns_records" \ | |
#-h "x-auth-email:[email protected]" \ | |
#-h "x-auth-key:YOUR_GLOBAL_API_KEY" \ | |
#-h "content-type: application/json" | |
NEW_IP=`curl -s http://ipv4.icanhazip.com` | |
CURRENT_IP=`cat /tmp/current_ip.txt` | |
if [ "$NEW_IP" = "$CURRENT_IP" ] | |
then | |
echo "No Change in IP Adddress" | |
else | |
curl -X PUT "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/dns_records/YOUR_RECORD_ID" \ | |
-H "X-Auth-Email: [email protected]" \ | |
-H "X-Auth-Key: YOUR_GLOBAL_API_KEY" \ | |
-H "Content-Type: application/json" \ | |
--data '{"type":"A","name":"YOUR-DDNS.exampel.com","content":"'$NEW_IP'","ttl":120,"proxied":false}' > /dev/null | |
echo $NEW_IP > /tmp/current_ip.txt | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment