Hi, I would like to build a script that enable “add default route” to all interface type ending “out” such (“pppoe-out”, “l2tp-out” and etc,)… I would like to know if there is a better way to do it,.. attached code that I wrote, It’s works but I would like to know if I can do it in another way (short way) such variable in command (/interface $CHANGEABLE-client set add-default-route=$drc $wan)…
:if ([:pick [/interface get value-name=type $wan] ([:find [/interface get value-name=type $wan] "-"]+1) [:len [/interface get value-name=type $wan]]]="out") do={
:local drc
if ([:tostr $mode]="enable") do={
:set $drc true
} else={
:set $drc false
}
:if (([:pick [/interface get value-name=type $wan] 0 [:find [/interface get value-name=type $wan] "-"]]="pppoe") && ([/interface pppoe-client get value-name=add-default-route $wan]!=$drc)) do={
/interface pppoe-client set add-default-route=$drc $wan
}
:if (([:pick [/interface get value-name=type $wan] 0 [:find [/interface get value-name=type $wan] "-"]]="l2tp") && ([/interface l2tp-client get value-name=add-default-route $wan]!=$drc)) do={
/interface l2tp-client set add-default-route=$drc $wan
}
:if (([:pick [/interface get value-name=type $wan] 0 [:find [/interface get value-name=type $wan] "-"]]="ppp") && ([/interface ppp-client get value-name=add-default-route $wan]!=$drc)) do={
/interface ppp-client set add-default-route=$drc $wan
}
:if (([:pick [/interface get value-name=type $wan] 0 [:find [/interface get value-name=type $wan] "-"]]="sstp") && ([/interface sstp-client get value-name=add-default-route $wan]!=$drc)) do={
/interface sstp-client set add-default-route=$drc $wan
}
}