Created
March 25, 2017 16:37
-
-
Save wolph/936c5a8e3486a9060c7cf2939de0c271 to your computer and use it in GitHub Desktop.
Mikrotik script to detect WAN IP updates and call scripts if it changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: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