Yesterday I added another port (nat rule #6), but whatever I do I can't get it (script) to update dst-address.
When pasted to terminal this line immediately updates specified nat rule
/ip firewall nat set 6 dst-address=$currentIP
Original script still updates nat rule #3.
I tried replacing 3 with 6 in original script and nothing happens.
What am I missing?
:global currentIP;
:local newIP [/ip address get [find interface="pppoe-out1"] address];
You should not use line numbers in a script. Best to use the “find” parameter.
The new port has a new name? Both show evaluating “pppoe-out1”.
You are also storing both IP addresses in the same variable. I changed that to currentIP1.
To check the other interface, you change “currentIP1” to “currentIP2”, and “pppoe-out1” to “pppoe-out2”.
I have not run this to check it.
ADD: Don’t use “:put” command in a script. Use “:log info” instead. Then check the log.
And my bad. I did not notice the set is not the same location. I had the “find” in “/ip address” and using it in “/ip firewall nat”. I set the comment on firewall rules to find them. Set rule 3 comment to “pppoe-out1” and set rule 6 comment to “pppoe-out2”.
Then use the above code. The coffee is working now!