SHARE
TWEET
Cloudflare DDNS with upnp
a guest
Jan 11th, 2019
93
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- #!/bin/sh
- content=$( upnpc -s | sed -n -e 's/ExternalIPAddress = \(.*\)/\1/p' )
- DNS_IP=$( dig __host__ @brenda.ns.cloudflare.com +short)
- WORKS=$?
- if [ "$content" = "" ]
- then
- echo "No IP address to set record value with."
- exit 1
- fi
- if [ "$content" = "$DNS_IP" ]
- then
- # echo "No need to update IP"
- exit 0
- fi
- key=__fill_me__
- email=__fill_me__
- zone=__fill_me__
- zone_id=__fill_me__
- rec_id=__fill_me__
- type=A
- name=__host__
- ttl=120
- proxied=false
- update_response=$(curl -X PUT "https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records/$rec_id" -H "X-Auth-Email
- : $email" -H "X-Auth-Key: $key" -H "Content-Type: application/json" --data "{\"id\":\"$rec_id\",\"type\":\"$type\",\"nam
- e\":\"$name\",\"content\":\"$content\",\"ttl\":$ttl,\"proxied\":$proxied}" -s) m
- success_val=`echo $update_response | sed -E "s/.+\"success\":(true|false).+/\1/g"`
- if [ "$success_val" = "true" ]
- then
- echo "Record Updated."
- else
- echo "Record update failed."
- echo $update_response
- exit 1
- fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
