Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Mikrotik script to detect WAN IP updates and call scripts if it changes.
:global wanInterface "wan1"
:global wanIP "$wanIP"
# Get the current IP on the interface
:local currentIPtemp [/ip address get [find interface="$wanInterface" disabled=no] address];
# IP without netmask
:local currentIP [:pick $currentIPtemp 0 ([:len $currentIPtemp]-3)];
:if ($currentIP != $wanIP) do={
/log info "wan ip changed from $wanIP to $currentIP"
:set wanIP $currentIP
/system script run ddns_freedns
/system script run hairpin_nat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment