Last active
June 4, 2018 15:12
-
-
Save alswl/b9b805b45fad6429d6c731a0bc769b28 to your computer and use it in GitHub Desktop.
crontabe for update ip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Auto update machine DNS domain via DNSPod API.(cache supported)