Community discussions

MikroTik App
 
redangel666
just joined
Topic Author
Posts: 1
Joined: Fri Nov 10, 2023 12:27 pm

Remove connection

Fri Nov 10, 2023 12:47 pm

/ip firewall connection
:global arrConnections [find dst-address~"^91.227.9[2-5]\\.*" and reply-dst-address~"10.104.255.117:"];
:foreach i in=$arrConnections do={
  :do {
  :if ([:typeof $i] = "id") do={
  remove $i;
  :log warning ($i." for ".[/ip/firewall/connection/get [find where .id=$i] src-address ]." is src-address");
  :log warning ($i." for ".[/ip/firewall/connection/get [find where .id=$i] dst-address ]." is dst-address");
  }
} on-error={:log warning ("Fail on ".$i)}
}    
Hello everyone! I'm trying to find the solution for 2 weeks .
When the script is running some connection is was disappeared and I get the error "script error: no such item (4)" on remove command (because I did not see ID connection warning)
and script is stopping.
On-error did not to work properly.
I tryed a lot of variants, but I get the error- "no such item":
1. /ip/firewall/connection/remove [find dst-address~....
2. :foreach i in=[ ip/firewall/connection/find where dst-address~...
3. :foreach i in=[ ip/firewall/connection/find where dst-address~... and timeout>30
4. :foreach i in=[/ip/firewall/connection/find dst-address~.... ] do={
:if ([/ip/firewall/connection/get [find where .id=$i]]) do={....

Please help me how to ignore the error or some other variants.
I read that somebody on\off connection tracker but this method is not good for me.
Thanks a lot, Marat

Who is online

Users browsing this forum: No registered users and 8 guests