/ip firewall nat set 0 to-addresses=192.168.4.4

/ip firewall nat set 0 to-addresses=192.168.4.4

this line works in the terminal, but when I saved it in the script list and clicked “Run Script”, it didn’t work.
I know there is something wrong with the “set 0”, but how can I correct it? :confused: I just want to change the first record of “/ip firewall nat”.
please help me. much much appreciated!

The number is used in that case is where “print” was used first. Without that being run first it doesn’t know about a number to look for. A much better option is to use the find function when running a script.

/ip firewall nat set [find comment="Your comment here"] to-addresses=192.168.4.4

That will search all NAT rules for that specific comment and change the to-address. You can run find against any firewall parameter that you want.

It works! Thanks a lot!