Enable multiple firewall rules based on find in script

Hi,

I’m trying to enable/disable multiple firewall rules based on find result.

I switched from:
/ip/firewall/filter/enable numbers=6,7

to:
/ip/firewall/filter/enable numbers=[find comment=“ddns_1”];
/ip/firewall/filter/enable numbers=[find comment=“ddns_2”];

Is it possible to combine two lines with find part to single?

Thanks.

That depends on what other comments you have in your firewall rules.
When there are no other comments with ddns in them you can use: [find comment~“ddns_”]
But of course that will fail when there is also a ddns_3 or extra_ddns_2 or something like that.

This works fine.
I have only two rules with comments ddns_1 and ddns_2. I have tested with additional ddns_3 and it also works.
Now I see that there is good reference in Scripting - RouterOS - MikroTik Documentation which I’ll check also.

Thanks for quick response.

Of course with “fail” I meant that “if ddns_3 exists it will enable that as well” while maybe you wanted only to enable ddns_1 and ddns_2.
So it depends on what you want if the solution works.
It is possible to make it match only ddns_1 and ddns_2 but that would make it more complicated, like “^ddns_[12]”