Community discussions

MikroTik App
 
teknospr
just joined
Topic Author
Posts: 1
Joined: Wed Jun 19, 2019 8:32 pm

Script to clear all firewall connections

Wed Jun 19, 2019 8:35 pm

Good day:

I need to create a script that clears all firewall connections if it detects a change in ISP. The problem we have is that when failover occurs, VoIP phones connection hang. This occurs in a place where internet is very unstable.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3372
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Script to clear all firewall connections

Thu Jun 20, 2019 2:20 pm

This should clear all connection, but not sure how to trigger it:
:foreach i in=[/ip firewall connection find] do={/ip firewall connection remove $i}
Did find a shorter version:
/ip firewall connection remove [find]
This may be used to clear only the sip sections (not tested):
/ip firewall connection remove [find where connection-type=sip] 
 
gotsprings
Forum Guru
Forum Guru
Posts: 2343
Joined: Mon May 14, 2012 9:30 pm

Re: Script to clear all firewall connections

Mon Jul 01, 2019 7:30 pm

This
/ip firewall connection remove [find]
I have this exact command in my netwatch when it checks if the Primary ISP's DNS server is there AFTER RECURSIVE ROUTING.

So it CLEARS all connections whether flipping too or away from the Primary ISP.