Schedule this at RouterOS boot:
:global previousIP value="0.0.0.0/0";
This is the script fixed for RouterOS 6.12
DO NOT ESCAPE ? WITH ANY.
If you want paste this on terminal, put \ before ?
But this script is intended to be used on scheduled script or terminal?
Obviously on script, then leave ? alone and do not escape anything, 6.x fetch not support escaped characters.
I fix all errors I have noticed, for example declaring LOCAL variables inside cycles, at the end of the cycle the local variables declared INSIDE the cycle are deleted…
:local noipuser value="MY-EMAIL@gmail.com";
:local noippass value="MY-PASSWORD";
:local noiphost value="MY-HOSTNAME.noip.me";
:local inetinterface value="ADSL";
:local currentIP value="0.0.0.0/0";
:local url value="http://dynupdate.no-ip.com/nic/update?myip=";
:if ([/interface get $inetinterface value-name=running] = true) do={
:set $currentIP value=[/ip address get [find where interface=$inetinterface] address];
:for i from=([:len $currentIP] - 1) to=0 do={
:if ([:pick $currentIP $i] = "/") do={
:set $currentIP value=[:pick $currentIP 0 $i];
}
}
:if ($currentIP != $previousIP) do={
:log info message=("No-IP: Current IP ".$currentIP." is not equal to previous IP, update needed");
:set $previousIP value=$currentIP;
:log info message=("No-IP: Sending update for ".$noiphost);
/tool fetch url=($url.$currentIP."&hostname=".$noiphost) user=$noipuser password=$noippass mode=http dst-path=("no_ip_ddns_update_".$noiphost.".txt");
:log info message=("No-IP: Host ".$noiphost." updated on No-IP with IP ".$currentIP);
} else={
:log info message=("No-IP: Previous IP ".$previousIP." is equal to current IP, no update needed");
}
} else={
:log info message=("No-IP: ".$inetinterface." is not currently running, so therefore will not update.");
}