|
本帖最后由 路由器砖家 于 2017-12-30 18:10 编辑
准备:
1. 拥有公网IP,这个是必须,没有的不用看了。
2. godaddy 注册域名,要最便宜的那种,什么org、info之类的域名。十几块一个,很方便。
3. 进入godaddy后台开发中心,拿到一个key,一个secret。
4. 填入godaddy.sh脚本中,设置每天定时运行该脚本。
5. 实测运行稳定,远程控制自己的路由,控制aria2、transmission下载,管理上网,很方便。
有问题回帖!理论上其他路由都行,只要有公网IP,我是基于padavan固件做的,感谢hiboy大大开发的稳定固件!!!
- #!/bin/bash
- # This script is used to check and update your GoDaddy DNS server to the IP address of your current internet connection.
- # Special thanks to mfox for his ps script
- # https://github.com/markafox/GoDaddy_Powershell_DDNS
- #
- # First go to GoDaddy developer site to create a developer account and get your key and secret
- #
- # https://developer.godaddy.com/getstarted
- # Be aware that there are 2 types of key and secret - one for the test server and one for the production server
- # Get a key and secret for the production server
- #
- #Update the first 4 variables with your information
-
- domain="your_domain_here.com" # your domain,放你的域名
- name="@" # name of A record to update
- key="your key here" # key for godaddy developer API,你的KEY
- secret="your secret here" # secret for godaddy developer API,你的SECRET,这两个需要去狗爹的后台找。
- headers="Authorization: sso-key $key:$secret"
- echo $headers
- result=$(curl -v -k -X GET -H "$headers" \
- "https://api.godaddy.com/v1/domains/$domain/records/A/$name")
- echo $result
- dnsIp=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
- echo "dnsIp======="$dnsIp
- # Get public ip address there are several websites that can do this.
- #ret=$(curl -s GET "http://ipinfo.io/json")
- #currentIp=$(echo $ret | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
- #currentIp=$(curl -s GET "http://45.76.166.156:81/ip.php?id=fomanto" | awk '{print $1}')
- #currentIp=$(curl -s GET "http://www.wifipineapple.com/ip.php"),我测试用这个网址来获取自己的公网IP,你可以替换自己的。
- currentIp=$(wget --no-check-certificate -q -O- "https://www.wifipineapple.com/ip.php")
- echo "currentIp==="$currentIp" "
- if [ "$dnsIp" != "$currentIp" ]; then
- echo "Ips are not equal"
- request='{"data":"'$currentIp'","ttl":600}'
- echo $request;
- nresult=$(curl -i -k -v -X PUT \
- -H "$headers" \
- -H "Content-Type: application/json" \
- -d $request "https://api.godaddy.com/v1/domains/$domain/records/A/$name")
- echo $nresult
- fi
复制代码 |
|