Community discussions

MikroTik App
 
Ernstm
just joined
Topic Author
Posts: 17
Joined: Mon Jun 23, 2008 10:03 am

Help with remove Command

Thu Feb 17, 2022 11:52 am

Hi

Please could someone assist me with this?

I need script to remove sip connections every hour. I have tried the following

/ip firewall connection remove [/ip firewall connection find where connection-type=sip]

I also tried to mark the connections and then
/ip firewall connection remove [/ip firewall connection find where connection-mark=SIP]

Also tried --- /ip firewall connection remove numbers=[/ip firewall connection find where connection-mark=SIP]
and --- /ip firewall connection remove numbers=[/ip firewall connection find where connection-type=sip]

None of these have any effect.

Please can someone show me what I am doing wrong?

Thanks
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3297
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Help with remove Command

Thu Feb 17, 2022 12:17 pm

What is the output of:
:put [/ip firewall connection find where connection-type=sip]
and
:put [/ip firewall connection find where connection-mark=SIP]
If its more than one, you may need to loop trough it.
 
pudl
just joined
Posts: 5
Joined: Wed Apr 16, 2014 2:32 pm

Re: Help with remove Command

Thu Mar 03, 2022 3:40 pm

I am using this script for removing rogue SIP connections:
:global SIP [ /ip firewall connection find where connection-type=sip and assured=no ];
:global SRC [ /ip firewall connection get $SIP src-address ];
:global DST [ /ip firewall connection get $SIP dst-address ];
:global currentSIP [ :toarray $SIP ];
:global message "SIP - delete non-assured connections: SRC:$SRC DST:$DST";

:if ( $currentSIP="" ) do={ 
                 /log info "SIP - no non-assured connections"
} else={
                /ip firewall connection remove $currentSIP;
#                /tool e-mail send server=******** user=******** password=******* to=******** body=$message;
               /log info "SIP - delete non-assured connections: SRC:$SRC DST:$DST";
              /tool e-mail send to="*********" subject="SIP!" body=$message;
	}
}
I set the scheduler to run it every 3 minutes.

Who is online

Users browsing this forum: No registered users and 13 guests