Created
July 10, 2019 16:40
-
-
Save arvati/b9c15c20cf0cfdbdce65a016b2e5292d to your computer and use it in GitHub Desktop.
Script to Update GoDaddy DNS dynamic up client
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 | |
# 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 | |
name="" # name of A record to update | |
key="" # key for godaddy developer API | |
secret="" # secret for godaddy developer API | |
headers="Authorization: sso-key $key:$secret" | |
# echo $headers | |
result=$(curl -s -X GET -H "$headers" \ | |
"https://api.godaddy.com/v1/domains/$domain/records/A/$name") | |
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") | |
# echo "currentIp:" $currentIp | |
if [ "dnsIp" != $currentIp ]; | |
then | |
# echo "Ips are not equal" | |
request='{"data":"'$currentIp'","ttl":3600}' | |
# echo $request | |
nresult=$(curl -i -s -X PUT \ | |
-H "$headers" \ | |
-H "Content-Type: application/json" \ | |
-d $request "https://api.godaddy.com/v1/domains/$domain/records/A/$name") | |
# echo $nresult | |
fi |
result=$(curl -s -X GET -H "$headers"
"https://api.godaddy.com/v1/domains/$domain/records/A/$name")
This line doen't return me a json..
Connection #0 to host api.godaddy.com left intact
Read this https://developer.godaddy.com/getstarted and try this command with yours secret and keys:
curl -X GET -H"Authorization: sso-key [API_KEY]:[API_SECRET]""https://api.godaddy.com/v1/domains/available?domain=example.guru"
Then step into this https://developer.godaddy.com/doc/endpoint/domains#/operations/v1/recordGet
Try it out iver there with yours parameters and pay attention on response code not just json results.
hope it helps.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read more info at:
https://github.com/binnychan/GoDaddy_Powershell_DDNS?files=1
https://github.com/leandrokoiti/GoDaddyDnsUpdater
https://github.com/markafox/GoDaddy_Powershell_DDNS
https://br.godaddy.com/community/Managing-Domains/Dynamic-DNS-Updates/td-p/7862