Skip to content

Instantly share code, notes, and snippets.

@alswl
Last active June 4, 2018 15:12
Show Gist options
  • Save alswl/b9b805b45fad6429d6c731a0bc769b28 to your computer and use it in GitHub Desktop.
Save alswl/b9b805b45fad6429d6c731a0bc769b28 to your computer and use it in GitHub Desktop.
crontabe for update ip
1/5 * * * * DEVICE="wlan0"; SUB_DOMAIN="eth0-pi"; BASE_DOMAIN="example.com"; DOMAIN="$SUB_DOMAIN.$BASE_DOMAIN"; DOMAIN_ID="11111111"; RECORD_ID="22222222"; TOKEN="33333,44444444444444444444444444444444"; IP=`ip addr | grep $DEVICE: -A 2 | grep inet | awk '{print $2}' | awk -F '/' '{print $1}'`; C_IP=`dig $DOMAIN | grep "^$DOMAIN" | awk '{print $5}'`; [ "$IP" = "$C_IP" ] && exit 0; [ -z $IP ] && exit 0; curl https://dnsapi.cn/Record.Modify -d "domain_id=$DOMAIN_ID&record_id=$RECORD_ID&sub_domain=$SUB_DOMAIN&record_type=A&record_line=默认&value=$IP&login_token=$TOKEN&format=json"
1/5 * * * * SUB_DOMAIN="eth0-pi"; BASE_DOMAIN="example.com"; DOMAIN="$SUB_DOMAIN.$BASE_DOMAIN"; DOMAIN_ID="11111111"; RECORD_ID="22222222"; TOKEN="33333,44444444444444444444444444444444"; IP=`dig +short myip.opendns.com @resolver1.opendns.com`; C_IP=`dig $DOMAIN | grep "^$DOMAIN" | awk '{print $5}'`; [ "$IP" = "$C_IP" ] && exit 0; [ -z $IP ] && exit 0; curl https://dnsapi.cn/Record.Modify -d "domain_id=$DOMAIN_ID&record_id=$RECORD_ID&sub_domain=$SUB_DOMAIN&record_type=A&record_line=默认&value=$IP&login_token=$TOKEN&format=json"
@alswl
Copy link
Author

alswl commented Jul 7, 2016

Auto update machine DNS domain via DNSPod API.(cache supported)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment