Skip to content

Instantly share code, notes, and snippets.

@luginbash
Created December 9, 2015 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luginbash/f9622e6cc15b5055096e to your computer and use it in GitHub Desktop.
Save luginbash/f9622e6cc15b5055096e to your computer and use it in GitHub Desktop.
Add interface IPv4 address to a global var
# Change to the name of interface that gets the dynamic IP address
:local inetinterface "pppoe-out1";
# use search & replace all on myEndpoint for multiple hosts
:global myEndpoint;
:if ([/interface get $inetinterface value-name=running]) do={
# Get the current IP on the interface
:local currentIP [/ip address get [find interface="$inetinterface" disabled=no] address];
# Strip the net mask off the IP address
:for i from=( [:len $currentIP] - 1) to=0 do={
:if ( [:pick $currentIP $i] = "/") do={
:set currentIP [:pick $currentIP 0 $i];
}
}
:if ($currentIP != $myEndpoint) do={
:set myEndpoint $currentIP;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment