Closed tomkap closed 6 years ago
Working for MikroTik RouterOS 6.x
The script (/system script ...):
:global ddnsuser "username" :global ddnspass "password" :global theinterface "interface" :global ddnshost hostname.nsupdate.info :global ipddns [:resolve $ddnshost]; :global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ] :if ([ :typeof $ipfresh ] = nil ) do={ :log info ("nsupdate.info: No ip address on $theinterface .") } else={ :for i from=( [:len $ipfresh] - 1) to=0 do={ :if ( [:pick $ipfresh $i] = "/") do={ :set ipfresh [:pick $ipfresh 0 $i]; } } :if ($ipddns != $ipfresh) do={ :log info ("nsupdate.info: IP = $ipddns") :log info ("nsupdate.info: IP-Fresh = $ipfresh") :log info "nsupdate.info: Update IP needed, Sending UPDATE...!" :global str "/nic/update\?hostname=$ddnshost&myip=$ipfresh" /tool fetch address=ipv4.nsupdate.info src-path=$str mode=http user=$ddnsuser \ password=$ddnspass dst-path=("/nsupdate.info.".$ddnshost) :delay 1 :global str [/file find name="nsupdate.info.$ddnshost"]; /file remove $str :global ipddns $ipfresh :log info "nsupdate.info: IP updated to $ipfresh!" } else={ :log info "nsupdate.info: dont need changes"; } }
The scheduler:
/system scheduler add interval=1m name=nsupdate.info on-event=nsupdate.info policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api start-time=startup
Hi. That is not a bug. Please, do a pull request (and pray to be accepted)
Praying doesn't work. But a pull request would save us some work.
Sorry I'm moving to gitlab, see you there
Working for MikroTik RouterOS 6.x
The script (/system script ...):
The scheduler: