daily pastebin goal
68%
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!
  1. #!/bin/sh
  2.  
  3. content=$( upnpc -s | sed -n -e 's/ExternalIPAddress = \(.*\)/\1/p' )
  4. DNS_IP=$( dig __host__ @brenda.ns.cloudflare.com +short)
  5. WORKS=$?
  6.  
  7. if [ "$content" = "" ]
  8.     then
  9.     echo "No IP address to set record value with."
  10.     exit 1
  11. fi
  12.  
  13. if [ "$content" = "$DNS_IP" ]
  14. then
  15. #   echo "No need to update IP"
  16.    exit 0
  17. fi
  18.  
  19.  
  20. key=__fill_me__
  21. email=__fill_me__
  22. zone=__fill_me__
  23. zone_id=__fill_me__
  24. rec_id=__fill_me__
  25. type=A
  26. name=__host__
  27. ttl=120
  28. proxied=false
  29.  
  30. update_response=$(curl -X PUT "https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records/$rec_id" -H "X-Auth-Email
  31. : $email" -H "X-Auth-Key: $key" -H "Content-Type: application/json" --data "{\"id\":\"$rec_id\",\"type\":\"$type\",\"nam
  32. e\":\"$name\",\"content\":\"$content\",\"ttl\":$ttl,\"proxied\":$proxied}" -s)                                         m
  33. success_val=`echo $update_response | sed -E "s/.+\"success\":(true|false).+/\1/g"`
  34. if [ "$success_val" = "true" ]
  35. then
  36.     echo "Record Updated."
  37. else
  38.     echo "Record update failed."
  39.     echo $update_response
  40.     exit 1
  41. 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. OK, I Understand
 
Top