Skip to content

Instantly share code, notes, and snippets.

@wolph
Created March 25, 2017 16:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wolph/936c5a8e3486a9060c7cf2939de0c271 to your computer and use it in GitHub Desktop.
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.
: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