-
Notifications
You must be signed in to change notification settings - Fork 0
/
dyndnsgd
14 lines (14 loc) · 845 Bytes
/
dyndnsgd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash
mydomain="Your-Domain-Name-Here.com"
myhostname="@"
gdapikey="Your-Godaddy-API-Key-Goes-Here"
logdest="local7.info"
myip=`curl -s "https://api.ipify.org"`
dnsdata=`curl -s -X GET -H "Authorization: sso-key ${gdapikey}" "https://api.godaddy.com/v1/domains/${mydomain}/records/A/${myhostname}"`
gdip=`echo $dnsdata | cut -d ',' -f 1 | tr -d '"' | cut -d ":" -f 2`
echo "`date '+%Y-%m-%d %H:%M:%S'` - Current External IP is $myip, GoDaddy DNS IP is $gdip"
if [ "$gdip" != "$myip" -a "$myip" != "" ]; then
echo "IP has changed!! Updating on GoDaddy"
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}\"}]"
logger -p $logdest "Changed IP on ${hostname}.${mydomain} from ${gdip} to ${myip}"
fi