Created
October 4, 2021 19:59
-
-
Save droM4X/8028d597d4508cc619f3415663f93448 to your computer and use it in GitHub Desktop.
Cloudflare dyndns 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
#!/bin/sh | |
DYN_HOST=''; | |
CF_BEARER_TOKEN=''; | |
CF_ZONE_ID=''; | |
CF_DNS_ID=''; | |
# --- | |
CURRENT_IP=$(curl -s https://checkip.amazonaws.com); | |
DNS_IP=$(resolveip -s $DYN_HOST); | |
if [ CURRENT_IP != DNS_IP ] | |
then | |
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/$CF_ZONE_ID/dns_records/$CF_DNS_ID" \ | |
-H "Authorization: Bearer $CF_BEARER_TOKEN" \ | |
-H "Content-Type:application/json" \ | |
--data '{"type":"A","name":"'$DYN_HOST'","content":"'$CURRENT_IP'","ttl":300,"proxied":false}' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment