do not mind ABCD in src-address and to-src-address, I deleted original numbers. Those rules are correct and work.
I would like to enable and disable those rules at specific times. As you can see, I have several tens of other src-nat rules, so I want to disable and enable ONLY those which comment begins with
preport-
Is is possible somehow? I’m very weak at scripting…
:foreach name in=john,jane,billy,bob,thornton,bong,smokey do={ / ip firewall src-nat disable ( "preport-" . $name ) }
RouterOS does not do string handling well (much to my dismay) meaning you kind of have to design around that (which we all hate). If you had designed the comments to be like “preport,billy” instead you could do:
:foreach rule in=[ / ip firewall src-nat find ] do={ :foreach name in=[ / ip firewall src-nat get $rule comment ] do={ :if ( $name = "preport" ) do={ / ip firewall src-nat disable $rule } } }