Hello everyone, I wanted to know if there is a way to create a script like this:
The default route is an IP gateway to capture the responsible interface and put it in a variable.
As in the image, if the script detects that the gateway is an ip, it captures the physical interface ether1 and puts the value ether1 in a variable
This error:
"input does not match any value of interface"
It only appears with the add mangle line....
Without it, just your script, the error does not come.
Latest version Long-term v6
Use this and post on forum the exact string you give, do not omit >< or other characters:
{
:local test [:tostr [/ip route get [find where dst-address=0.0.0.0/0 and ([:typeof [:toip (($gateway)->0)]] = "ip")] gateway-status]]
:put ">$test<"
}
The idea is the same as you did in the first code, remove everything and leave only "ether1" in the variable's value, then use this variable in the mangle rule, as an example.
Here in this part:
connection-state=new out-interface=ether1
I use the variable, getting
connection-state=new out-interface=$test
And then comes the error.
my route table, I’m testing with more than one default wheel.
As using PPPoE I use another script that does this already, creates the mangle rules using the variable and added the pppoe interface
I just did the test with your script and it worked fine. But in case you have two routes, in the same way using IP for different interfaces, it returns this error:
invalid internal item number
I think it’s because it has two interfaces, I believe it would be a totally different script, correct? Example:
The script is just for obtain a result to project script as needed.
Obviously if result are not one single value, but one array, the script must be changed accordingly.