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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jy02239285
可以参考下这篇讨论:https://forum.archive.openwrt.org/viewtopic.php?id=58603