I’m probably too deep in the weeds and am missing something obvious here, but I’m running a script to determine the current outbound interface and can’t get the find command to pull data from a variable.
So… the immediateGateway local variable gets assigned, but I can’t get the pick/find to pull from the value. I’ve tried putting the variable in raw, putting it in quoted, and doing the pick/find with the actual value itself. Doing the pick/find seems to work with the value of the variable, but I’m having no luck with getting find command to pick up the variable itself.
You can have multiple routes per IP, you can iterate find like this:
/ip/route
:foreach routeId in=[find where 8.8.8.8 in dst-address and active and routing-table=main] do={
:local immediateGateway ([get $routeId]->"immediate-gw")
:put "immediateGateway: $immediateGateway"
}