這篇文章主要是針對RouterOS更新到DynDNS上所寫的
如果你要更新到ChangeIP.com的話,請參考RouterOS 動態更新IP到 ChangeIP.com
請先到RouterOS 動態更新IP到 ChangeIP.com看一下其他的相關的設定
再把主要的Script換成本文的Script即可。
相關的Script如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #Script在RouterOS 5.0rc11中測試過 #Date:2010/04/11 #Script Name:DynDNSUpdate #Script Describe:更新IP到DynDNS上面去 #定義使用者相關的變數,請於下面自行輸入 : local ddnsuser "你的DynDNS帳號" : local ddnspass "你的DynDNS密碼" : local ddnshost "你的完整網址名(例如:abcd.ath.cx)" : local ddnsinterface "要更新的介面名稱(例如: pppoe -out1)" #定義IP變數 : global ddnsipADSL1 : global ddnslastipADSL1 : if ([ : typeof $ddnslastipADSL1 ] = nil ) do ={ $ddnslastipADSL1 "0" } #取得介面的IP位置 : set ddnsipADSL1 [ / ip address get [/ ip address find interface =$ddnsinterface ] address ] #去掉IP的網段 : set ddnsipADSL1 [: pick $ddnsipADSL1 0 [: find $ddnsipADSL1 "/"]] #判斷是否需要進行更新 : if ([ : typeof $ddnsipADSL1 ] = nil ) do ={ : log info ("DynDNS: " . $ddnsinterface . "介面上沒有 IP ,請確認") } else={ : if ($ddnsipADSL1 != $ddnslastipADSL1) do ={ : log info ("DynDNS:" . $ddnsinterface . "更新 IP " . $ddnsipADSL1) : local str "/nic / update?hostname=$ddnshost&myip=$ddnsipADSL1&wildcard = NOCHG&mx = NOCHG&backmx = NOCHG" / tool fetch address = members.dyndns.org src-path=$str mode = http user =$ddnsuser password =$ddnspass dst-path=("/DynDNS.".$ddnshost) : delay 1 : local str [/ file find name ="DynDNS.$ddnshost"]; / file remove $str #更新後把IP設為最新的IP : global ddnslastipADSL1 $ddnsipADSL1 } } |
參考資料:
MikroTik RouterOS: DynDNS Update Script
DynDNS Perform Update
One thought on “RouterOS 動態更新IP到 DynDNS”