RouterOS V5.x 版的 DDNS for ChangeIP 腳本

RouterOS V5.x 版的 DDNS for ChangeIP 腳本

:global ddnsuser “ChangeIP的帳號”
:global ddnspass “ChangeIP的密碼”
:global ddnshost “您所申請的DDNS網址”
:global ddnsinterface “pppoe-out那片網卡介面名稱”

:global ddnssystem (“mt-” . [/system package get [/system package find name=system] version] )
:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface] address ]
:global ddnslastip

:if ([:len [/interface find name=$ddnsinterface]] = 0 ) do={ :log info “DDNS: No interface named $ddnsinterface, please check configuration.” }

:if ([ :typeof $ddnslastip ] = “nothing” ) do={ :global ddnslastip 0.0.0.0/0 }

:if ([ :typeof $ddnsip ] = “nothing” ) do={

:log info (“DDNS: No ip address present on ” . $ddnsinterface . “, please check.”)

} else={

  :if ($ddnsip != $ddnslastip) do={

    :log info “DDNS: Sending UPDATE!”
    :log info [ :put [/tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip “/”] ] key-name=$ddnsuser key=$ddnspass ] ]
    :global ddnslastip $ddnsip

  } else={

    :log info “DDNS: No changes necessary.”

  }

}

本篇發表於 RouterOS。將永久鏈結加入書籤。

RouterOS V5.x 版的 DDNS for ChangeIP 腳本 有 2 則回應

  1. 通告: RouterOS 教學索引 | Mikrotik元芳

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *