Script to Clean Firewall->Connections after public IP Changes

for close ALL connection open ath the moment you launch te command:
(this ignore any connection made, or closed, exactly after the first [find] command inside the script)

/ip fire conn
:foreach idc in=[find where timeout>60] do={
 remove [find where .id=$idc]
}

the “timeout>60” and the second “find” preventing errors from connection already closed in meantime script execution :wink:


for remove ONLY NATted connection with prevoious invalid IP:
(DO NOT REMOVE QUOTE AND PASS THE PARAMETER AS STRING, NOT IP!!!)

:global previousIP "18.11.23.33"

/ip fire conn
:foreach idc in=[find where timeout>60 and reply-dst-address~$previousIP] do={
 remove [find where .id=$idc]
}

on pppoe-client connection can be used this as on-up script on actual pppoe-client profile

:global newIP [:tostr $"local-address"]

/ip fire conn
:foreach idc in=[find where timeout>60 and (!(reply-dst-address~$newIP))] do={
 remove [find where .id=$idc]
}