Mikrotik script get Public IP

/tool fetch url="http://ifconfig.co/ip" mode=http dst-path=mypublicip.txt
:local ipku [file get mypublicip.txt contents]
:global ipnow "";
:global ipold;
:for i from=0 to=([:len $ipku]-1) do={ :local tmp [:pick $ipku $i];
:if ($tmp !="\n") do={ :set ipnow "$ipnow$tmp" }
}

:if ($ipnow != $ipold) do={ 
:log info "ip diupdate"; 
:set ipold "$ipnow";
/tool fetch url="http://xxx.xxx/update.php\3Fip=$ipnow" keep-result=no;
} else={ :log info "Tidak diupdate"}

:log info $ipnow

Leave a Reply

Your email address will not be published. Required fields are marked *