how can I NOT remove the default route here if WAN1 is found?
Code: Select all
if ([/interface get WAN1]) do={/ip route remove [/ip route find dst-address=0.0.0.0/0]}
if ([/interface get WAN1]) do={/ip route remove [/ip route find dst-address=0.0.0.0/0]}
if (![/interface get WAN1]) do={/ip route remove [/ip route find dst-address=0.0.0.0/0]}
if ([/interface get WAN1]) do={} else={/ip route remove [/ip route find dst-address=0.0.0.0/0]}
:put [/interface get WAN1]
# if 0 interface named WAN1 is found, delete (all) routes that have 0.0.0.0/0 as destination address
:if ([:len [/interface find where name="WAN1"]] = 0) do={ /ip route remove [find where dst-address=0.0.0.0/0] }
# if (exactly) 1 interface named WAN1 is found, delete (all) routes that have 0.0.0.0/0 as destination address
:if ([:len [/interface find where name="WAN1"]] = 1) do={ /ip route remove [find where dst-address=0.0.0.0/0] }