routeros-add-script/updateIpCloudIfNotUpToDate.txt

20 lines
658 B
Plaintext
Raw Normal View History

2024-03-31 23:48:30 +03:00
{
do {
#get current external IP
:local currentIP [:resolve myip.opendns.com server=resolver1.opendns.com];
:local resolvedIP;
# Determine if DNS update is needed
:if ($currentIP != $resolvedIP) do={
:log info "Mynetname update needed: Current-IP: $currentIP Resolved-IP: $resolvedIP";
/ip/cloud/force-update;
:local resolvedIP [:resolve myip.opendns.com server=resolver1.opendns.com];
} else={
:local resolvedIP [:resolve myip.opendns.com server=resolver1.opendns.com];
#:log info "Mynetname: No update needed $currentIP equals $resolvedIP";
}
} on-error={
:log info "Error force-update";
}
}