Last active
June 9, 2021 22:25
-
-
Save HouCoder/bd9b5b1542e5baa5b75be35b5e80a3fd to your computer and use it in GitHub Desktop.
Godaddy DNS record updater.
This file contains 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
#!/bin/bash | |
# https://developer.godaddy.com/keys | |
KEY="" | |
SECRET="" | |
domain="example.com" | |
name="a-record" | |
# Get public IP from ipinfo.io | |
public_ip="$(curl --silent ipinfo.io/ip)" | |
# get current record | |
current_record="$(dig @8.8.8.8 +short $name.$domain)" | |
if [ "$current_record" != "$public_ip" ]; then | |
echo New public IP is $public_ip | |
# Update godaddy A record - https://developer.godaddy.com/doc/endpoint/domains#/v1/recordReplaceTypeName | |
curl -X PUT "https://api.godaddy.com/v1/domains/$domain/records/A/$name" \ | |
-H "Authorization: sso-key $KEY:$SECRET" \ | |
-H 'Content-Type: application/json' \ | |
--data '[{"type": "A", "name": "'"$name"'", "data": "'"$public_ip"'", "ttl": 3600}]' | |
else | |
echo Nothing changed | |
fi |
我用的是centos7提示:line 22: syntax error near unexpected token `fi'
并且我打印echo $current_record打印不出值,有没联系方式教我一下我的q3006139
路由器运行sh
错误提示
[Router /home/id]# ./godaddy_ddns.sh
New public IP is 100.11.xx.xx
curl: (51) Cert verify failed: BADCERT_NOT_TRUSTED
如果我使用跳过
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
则提示
syntax error: unexpected word (expecting ")")
头疼,暂时还没看到godaddy更新ip.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
哦,你需要安装 dig 这个工具,ubuntu 的话应该是
$ sudo apt-get install dnsutils
就可以了。@unit2nd