Mikrotik ChangeIP script

This is my script for changeip. Tested and working with 6.34.2.

Add this script to System -> Scheduler with read, write, policy, test permissions. Replace variables with yours.


:local ddnsUser "login"
:local ddnsPass "password"
:local ddnsHost "fqdn"
:local ddnsInterface "dynamic-interface-name"
:local currentIp [ /ip address get [find interface=$ddnsInterface disabled=no] address ]

:global ddnsSavedIp

:if ( ( $ddnsSavedIp != $currentIp ) || ( [:typeof $ddnsSavedIp] = nil ) ) do={
/tool dns-update name=$ddnsHost address=[:pick $currentIp 0 [:find $currentIp "/"] ] key-name=$ddnsUser key=$ddnsPass
:set ddnsSavedIp $currentIp
}

Mikrotik ChangeIP script

Leave a comment