Skip to content

Instantly share code, notes, and snippets.

@pandada8
Created January 2, 2016 14:56
Show Gist options
  • Save pandada8/e5e265003391c17efd2a to your computer and use it in GitHub Desktop.
Save pandada8/e5e265003391c17efd2a to your computer and use it in GitHub Desktop.
INTERFACE="eth0.2"
DOMAIN=""
SUBDOMAIN=$(echo $DOMAIN | cut -d. -f1)
IP=$(ifconfig $INTERFACE | awk '/inet addr/ {gsub("addr:", "", $2); print $2}')
echo "get ip address $IP";
ORIGIN=$(curl "119.29.29.29/d?dn=$DOMAIN" 2>/dev/null)
echo "get origin ip address $ORIGIN"
DOMAIN_ID=""
RECORD_ID=""
TOKEN=""
if [[ "$IP" != "$ORIGIN" ]] ; then
echo "Updating";
curl -k -X POST https://dnsapi.cn/Record.Modify -d "login_token=$TOKEN&format=json&domain_id=$DOMAIN_ID&record_id=$RECORD_ID&sub_domain=$SUBDOMAIN&value=$IP&record_type=A&record_line=%E9%BB%98%E8%AE%A4"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment