RouterOS version: 6.39.2
Google Domains 有支援 DDNS, 這個 script 就是用來在 MikroTik RouterOS 中更新 Google Domains DDNS 位址的。
# script name: update_google_ddns
# Google domains automatic Dynamic DNS update
#--------------- Change Values in this section to match your setup ------------------
# 設定 Google domains DDNS 提供用來更新憑證的帳號密碼, 不是一般的 Google 帳號密碼
:local GoogleDNSUsername "使用者名稱"
:local GoogleDNSPassword "密碼"
# Set the hostname or label of network to be updated. ex: "ladsai.com"
:local hostName "要更新的domain name"
# Change to the name of interface that gets the dynamic IP address. ex: "pppoe-out1"
:local inetinterface "你的pppoe連線名稱"
#------------------------------------------------------------------------------------
# No more changes need
:global previousIP
:local setResults ""
:if ([/interface get $inetinterface value-name=running]) do={
# Get the current IP on the interface
:local currentIP [/ip address get [find interface="$inetinterface" disabled=no] address]
# Strip the net mask off the IP address
:for i from=( [:len $currentIP] - 1) to=0 do={
:if ( [:pick $currentIP $i] = "/") do={
:set currentIP [:pick $currentIP 0 $i]
}
}
:do {
:if ($currentIP != $previousIP) 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];
:set previousIP $currentIP
:log info ("GoogleDNS said this: $setResults")
}
} on-error={
:set previousIP ""
}
} else={
:log info "$inetinterface is not currently running, so therefore will not update."
}
Interval: 排程間隔執行時間,例如: 00:01:00 表示間隔1分鐘執行一次。
On Event: 要執行的 script 名稱。


