Code: Select all
/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)}
}
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