Trying to figure out what I’m doing wrong in my script here.
I’m using 2 global variable on 2 netwatch-ed IP’s. One is an Internal IP of the ADSL modem the second is the External IP of the ADSL modem.
The scripting is supposed to automatically disable some mangle rules if the ADSL modem is unreachable on either IP address (if the ADSL modem has no power or there is no DSL sync/connection)
I’m trying to use the global variable to confirm that both IP addresses respond before the mangle rules are turned back on again but I seem to have a problem with the global variable for one not recognised on the other.
Below are the scripts I have on both netwatch entries.
On local IP Up
:global elo "1"
:if ([$elo + $dsl="2"]) do={
:foreach i in [/ip firewall mangle find] do={
:if ([:find [/ip firewall mangle get $i comment] "Netwatch_Toggle"]=0) do={
/ip firewall mangle set $i disabled=no
}
}
}
On local IP Down
:global elo "0"
:foreach i in [/ip firewall mangle find] do={
:if ([:find [/ip firewall mangle get $i comment] "Netwatch_Toggle"]=0) do={
/ip firewall mangle set $i disabled=yes
}
}
On ADSL IP Up
:global dsl "1"
:if ([$elo + $dsl="2"]) do={
:foreach i in [/ip firewall mangle find] do={
:if ([:find [/ip firewall mangle get $i comment] "Netwatch_Toggle"]=0) do={
/ip firewall mangle set $i disabled=no
}
}
}
On ADSL IP Down
:global dsl "0"
:foreach i in [/ip firewall mangle find] do={
:if ([:find [/ip firewall mangle get $i comment] "Netwatch_Toggle"]=0) do={
/ip firewall mangle set $i disabled=yes
}
}