Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 19714

Scripting • Re: Delete all connection in Firewall-Connections

$
0
0
So basically if you want all your FW connection tracking rules to be flushed you can't do it with a button click on winbox but with
Code:
/ip/firewall/connection/print where (timeout>15) [remove $".id"]
I can check it but my script worked fine, maybe this specific one liner is better or faster to some degree.
But, Error handling is normal in programming so I do not see why I should prefer a one liner? what makes it better?
The only difference is that there is a loop but technically speaking what's the real difference between using a one liner to implement inside a for loop or a while loop compared to an "on-error"?
I can run a for loop on every single one of the entries (30-40k) and with a do { } on-error {} on a single remove action.
Code:
{:log info "Starting FW connection tacking cleanup";:do {:foreach entery in=[/ip/firewall/connection/find] do={/ip/firewall/connection/remove $entery;}} on-error={:log info "error 1 removing FW connection";}:log info "Fininshed FW connection tacking cleanup";}
The above will run even without making sure any 10 or 15 or 30 or 60...

Statistics: Posted by elico — Fri Mar 15, 2024 10:46 pm



Viewing all articles
Browse latest Browse all 19714