Page 1 of 1

Help with remove Command

Posted: Thu Feb 17, 2022 11:52 am
by Ernstm
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

Re: Help with remove Command

Posted: Thu Feb 17, 2022 12:17 pm
by Jotne
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.

Re: Help with remove Command

Posted: Thu Mar 03, 2022 3:40 pm
by pudl
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.