Community discussions

MikroTik App
 
hydroksyde
just joined
Topic Author
Posts: 19
Joined: Fri May 31, 2013 11:54 pm

Excluding dynamic entries from [ find ]

Tue Mar 02, 2021 1:42 am

If I want to dump the old firewall rules out before adding a new set I use
/ip firewall filter
remove [ find ]
The trouble is that if there is a fasttrack rule, [ find ] returns the dynamic packet counter entry, and remove fails and the script stops executing the current code block. I'm not sure to specify non-dynamic entries to the find command

My current workaround is like this, but I'd like to know if there's a way to identify dynamic entries with find as I potentially have this problem in other places as well, such as removing static entries from the routing table
/ip firewall filter
remove [ find action!=passthrough ]
 
martinclaro
Frequent Visitor
Frequent Visitor
Posts: 95
Joined: Sat Sep 28, 2013 6:08 am
Location: Buenos Aires, Argentina
Contact:

Re: Excluding dynamic entries from [ find ]

Tue Mar 02, 2021 4:19 am

remove [find where !dynamic]
 
User avatar
karlisi
Member
Member
Posts: 438
Joined: Mon May 31, 2004 8:09 am
Location: Latvia

Re: Excluding dynamic entries from [ find ]

Tue Mar 02, 2021 8:44 am

or
remove [find dynamic=no]
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3297
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Excluding dynamic entries from [ find ]

Tue Mar 02, 2021 10:21 am

Or you can use on-error.
But above solutions are better.

Not sure why you like to remove all firewall rules, can you explain what is the goal with this?

Who is online

Users browsing this forum: roemer and 16 guests