Skip to content

Instantly share code, notes, and snippets.

@0x2f0713
Forked from morph027/cloudns_update
Created September 6, 2020 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0x2f0713/be07636fa9eec16ca14598aab7e07061 to your computer and use it in GitHub Desktop.
Save 0x2f0713/be07636fa9eec16ca14598aab7e07061 to your computer and use it in GitHub Desktop.
update cloudns ddns from plain OpenWRT
#!/bin/ash
CURRENT_IP=$(wget -q http://whatismyip.akamai.com/ -O -)
CLOUDNS_HANDLE="example.com" # <<<--- YOUR DNS NAME
CLOUDNS_SERVER=109.201.133.194 # DNS SERVER
echo "current IP: $CURRENT_IP"
DNS_IP=$(nslookup $CLOUDNS_HANDLE $CLOUDNS_SERVER | awk '/guest-wan.pw.cloudns.pro/,/Address/' | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
echo "DNS IP: $DNS_IP"
case $DNS_IP in
"$CURRENT_IP")
exit 0
;;
*)
URL="XXX" # <<<--- THIS IS YOU API TOKEN FROM CLOUDNS DASHBOARD
wget -q http://ipv4.cloudns.net/api/dynamicURL/?q="$URL" -O /dev/null
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment