PLEASE everyone i am trying to delete routes that appears twice on my routing table, i ran the following script to no avail ; really new to this stuff
:global countWan 0;
:while(/ip route find [comment=“WAN1” dst-address=0.0.0.0/] do { :set countWan($countWan+1);}
:if ($countWan=0) do
{
/ip route add gateway= lte1 dst-address=0.0.0.0/0 comment=“WAN1” }
else ={ :if ($countWan1>)1 {
/ip route remove [ find comment =“WAN1”]
}
}
Something like this should work (adjust as needed):
/ip route
:if ([:len [find comment="WAN1" dst-address=0.0.0.0/0]] > 0) do={
:foreach i in=[find comment="WAN1" dst-address=0.0.0.0/0] do={
remove $i
}
/ip route add gateway=lte1 dst-address=0.0.0.0/0 comment="WAN1"
}
:put [:typeof 0.0.0.0/ ]
str
:put [:typeof 0.0.0.0/0 ]
ip-prefix
Why appear twice the routes? Is the right question.
Disable add-default-route on lte profile, not?
I have rewrited the script, try to understand what you try to do.
/ip route
:global arrayWan [find where comment="WAN1" and dst-address=0.0.0.0/0]
:global countWan [:len $arrayWan]
:if ($countWan > 0) do={
remove $arrayWan
} else={
add gateway=lte1 comment="WAN1"
}