Code: Select all
# Variables
# Username and password are the long cryptic ones Google Domains provides,
# not your regular Google account ones
:local GoogleDNSUsername "gbML26UKGdjm7Oz1"
:local GoogleDNSPassword "ASmwlKjCAkEywaZC"
:local hostName "test.twinstar5.com"
:local currentIP ""
:local setResults ""
:local previousIP ""
# Script
:set currentIP [/ip cloud get public-address]
:set previousIP [:resolve "$hostName"]
:if ($currentIP != $previousIP) do={
:do {
/tool fetch url="https://$GoogleDNSUsername:$GoogleDNSPassword@domains.google.com/nic/update?hostname=$hostName&myip=$currentIP" mode=https dst-path=GoogleDNS.txt
:set setResults [/file get GoogleDNS.txt contents];
:log info ("GoogleDNS said this: $setResults")
} on-error={
:log error ("GoogleDNS: script failed to set new IP address")
}
}