Page 1 of 1
change out interface in ip firewall nat
Posted: Sat Mar 09, 2013 11:22 pm
by nmaton
I'm unable to change the out-interface in ip firewall nat with a script.
I have the following set in a script :
/ip firewall nat set numbers=9 out-interface=<pptp-test>
When i issue that command in terminal the out-interface gets adjusted but not when it's run from a script.
Any ideas on how to change this ?
thanks
Re: change out interface in ip firewall nat
Posted: Sun Mar 10, 2013 12:35 am
by ditonet
Add comment to this NAT rule (e.g. 'my_NAT_rule') and use following command:
ros code
/ip firewall nat set [find comment="my_NAT_rule"] out-interface=<pptp-test>
HTH,
Re: change out interface in ip firewall nat
Posted: Sun Mar 10, 2013 1:26 am
by jgellis
ditonet is correct.
The "number" attribute you see when printing in the terminal (i.e. 9 in your script) is not a configuration item on the nat rules. They are generated during a print command only. To set or get any values in a script you should always use the [find] command to narrow your results. [find] by itself would return all nat rules in this case, [find comment="blah"] would return only those with that exact comment, [find comment="blah" chain=forward] would return... well you probably get it by now.
If you cannot find it dynamically/uniquely using attributes set within the rule, then I do exactly what ditonet suggests, give it a unique comment and [find] it by that.
Re: change out interface in ip firewall nat
Posted: Sun Mar 10, 2013 1:41 am
by nmaton
Great info thank you all.
I had no idea scripting worked that way.
Thanks again