Community discussions

 
tristanwalter
just joined
Topic Author
Posts: 5
Joined: Wed Aug 03, 2016 6:37 am

GoDaddy Dynamic DNS

Mon Jul 09, 2018 7:14 pm

New to Mikrotik scripting and looking for help. I have a PowerShell script I want to convert to a Mikrotik script. The script is to update IP for GoDaddy hosted domain. I'd like to pull the IP address from the interface rather then an external site.
$domain = 'your.domain.to.update'  # your domain
$name = 'name_of_host' #name of the A record to update
$key = 'key' #key for godaddy developer API
$secret = 'Secret' #Secret for godday developer API

$headers = @{}
$headers["Authorization"] = 'sso-key ' + $key + ':' + $secret
$result = Invoke-WebRequest https://api.godaddy.com/v1/domains/$domain/records/A/$name -method get -headers $headers
$content = ConvertFrom-Json $result.content
$dnsIp = $content.data

# Get public ip address there are several websites that can do this.
$currentIp = Invoke-RestMethod http://ipinfo.io/json | Select -exp ip

if ( $currentIp -ne $dnsIp) {
    $Request = @{ttl=3600;data=$currentIp }
    $JSON = Convertto-Json $request
    Invoke-WebRequest https://api.godaddy.com/v1/domains/$domain/records/A/$name -method put -headers $headers -Body $json -ContentType "application/json"
}
Alternatively here it is as a bash script
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
 
tristanwalter
just joined
Topic Author
Posts: 5
Joined: Wed Aug 03, 2016 6:37 am

Re: GoDaddy Dynamic DNS

Mon Jul 09, 2018 9:08 pm

will using the following syntax use the variables?

:local headers "Authorization: sso-key $usrkey:$usrsecret"
 
tristanwalter
just joined
Topic Author
Posts: 5
Joined: Wed Aug 03, 2016 6:37 am

Re: GoDaddy Dynamic DNS

Mon Jul 09, 2018 10:01 pm

Does anyone know a way to send a custom header like the -H function for curl using Mikrotik Fetch tool?
 
tristanwalter
just joined
Topic Author
Posts: 5
Joined: Wed Aug 03, 2016 6:37 am

Re: GoDaddy Dynamic DNS

Thu Jul 12, 2018 9:15 pm

Found DomainConnect DDNS that'll run on local machines as it appears MikroTik Fetch tool doesn't yet support editing headers which is required for authentication with GoDaddy api. I have written everything for Mikrotik so hopefully when header editing is added I can add the necessary commands.
 
nansenat16
just joined
Posts: 1
Joined: Fri Aug 02, 2019 5:55 pm

Re: GoDaddy Dynamic DNS

Fri Aug 02, 2019 6:23 pm

 
tristanwalter
just joined
Topic Author
Posts: 5
Joined: Wed Aug 03, 2016 6:37 am

Re: GoDaddy Dynamic DNS

Mon Aug 05, 2019 5:35 pm

Thank you nansenat16 for the example. I see that since 6.44 http-header-field has been added. I had been busy correcting issues with the 6.44.x updates that I haven't noticed the fetch changes.
 
Tdaddysimi
Frequent Visitor
Frequent Visitor
Posts: 88
Joined: Wed Sep 28, 2016 4:37 pm
Location: Minnesota

Re: GoDaddy Dynamic DNS

Wed Aug 07, 2019 5:33 pm

Any update on this? I have a couple godaddy domains i'd like my tik to auto update to.
 
jdodge
just joined
Posts: 2
Joined: Mon Aug 05, 2019 11:05 pm

Re: GoDaddy Dynamic DNS

Mon Aug 12, 2019 9:13 pm

Have you thought about using the <your mac here>.sn.mynetname.net built into the OS under IP > Cloud?
For instance if you own stuff.net as a godaddy (ugh!) domain and wanted omaha.stuff.net to resolve to your router's wan - you use Mikrotik's built in myname.net address as a cname target.
Let's say yours is 830708af0128.sn.myname.net -- you then create a cname for omaha.stuff.net and point it to 830708af0128.sn.myname.net. It's what I've been doing for a while now -- works with any DNS provider, even one that doesn't natively support DDNS entries and updating. I have not as of yet had a problem with it. If you replace the router -- you have a new mac/address - you just update your cname entry to the new one. If you change DNS provider -- it's a simple move -- no client change.

Who is online

Users browsing this forum: No registered users and 7 guests