[SOLVED] Update address-list record for dynamic IP

Hello,

What I am trying to achieve
Allow incoming connections at location A from an IP that is dynamic at location B, using address-list.
Every 5-10 minutes, run a script that pings hostname.no-ip.org and updates the address-list record with the new IP if it is changed.

What I have so far
The host behind the dynamic IP at location B is using no-ip.com DynDNS service and I know the hostname.no-ip.org
Location A is using a MT CCR router.

I read most of the forum’s posts but found nothing similar.
Maybe someone else is using the same method and can help me with some script examples please?

Thank you.


Later edit:

With help from varios places on MT forums and wiki, came up with a simple script that can do it :slight_smile:

# Set listname to Address List name
:local listname dynamic


:local content
:local newip
:local oldip

:foreach i in=[/ip firewall address-list find list="$listname" and disabled=no] do={
:set content [/ip firewall address-list get $i comment]
:set oldip [/ip firewall address-list get $i address]
:do {
:set newip [:resolve $content]
} on-error={ 
:log info "Unable to resolve $content"
}
: if ($newip != $oldip) do={
/ip firewall address-list set $i address=$newip
:log info "Hostname to IP action: $content ip address changed: $oldip -> $newip" 
}
}

Still have to find a fix for resolve not timing out in case of error