Skip to content

Commit e4a0500

Browse files
authoredFeb 28, 2022
Create dyndnsgd
1 parent 526a75c commit e4a0500

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

‎dyndnsgd

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
mydomain="Your-Domain-Name-Here.com"
3+
myhostname="@"
4+
gdapikey="Your-Godaddy-API-Key-Goes-Here"
5+
logdest="local7.info"
6+
myip=`curl -s "https://api.ipify.org"`
7+
dnsdata=`curl -s -X GET -H "Authorization: sso-key ${gdapikey}" "https://api.godaddy.com/v1/domains/${mydomain}/records/A/${myhostname}"`
8+
gdip=`echo $dnsdata | cut -d ',' -f 1 | tr -d '"' | cut -d ":" -f 2`
9+
echo "`date '+%Y-%m-%d %H:%M:%S'` - Current External IP is $myip, GoDaddy DNS IP is $gdip"
10+
if [ "$gdip" != "$myip" -a "$myip" != "" ]; then
11+
echo "IP has changed!! Updating on GoDaddy"
12+
curl -s -X PUT "https://api.godaddy.com/v1/domains/${mydomain}/records/A/${myhostname}" -H "Authorization: sso-key ${gdapikey}" -H "Content-Type: application/json" -d "[{\"data\": \"${myip}\"}]"
13+
logger -p $logdest "Changed IP on ${hostname}.${mydomain} from ${gdip} to ${myip}"
14+
fi

0 commit comments

Comments
 (0)
Please sign in to comment.