Hi there,
Is there any possibility to delete with only one command ALL address lists present into the firewall?
Hi there,
Is there any possibility to delete with only one command ALL address lists present into the firewall?
Do mean connections?
Did you see this post, posted yesterday?
http://forum.mikrotik.com/t/script-to-clear-all-firewall-connections/131000/1
not connections, but all address list entry
This should do and its close to the command in the other post I did posted.
/ip firewall address-list remove [find]
Take care, this deletes all entries from all lists.
To delete one list, do this:
/ip firewall address-list remove [find where list=your_list]
Hello and thanks for your answer.
I tried both your command
Last test I did:
/ip firewall address-list remove [find where list="TEST-IP"]
Many times I got this error:
no such item (4)
I’ve noticed that using this command not ALL IPs of that address-list were deleted.
Each time I repeat the same command, new IPs were deleted.
Is it my fault?
I’m using 6.42.11 version
Still having this probelm even with 6.44.6
no such item (4)
:do { /ip firewall address-list remove [find where list="TEST-IP"] } on-error={}
This will ignore the no such item.
I hope that you are using a more recent release of RouterOS and don’t forget to make backups from your configuration.
Thanks for your kind answer
This code is still not deleting all address lists
:do { /ip firewall address-list remove [find] } on-error={}
Most of the entries remains after entering the command
I can’t try it but you can.
/ip firewall address-list remove
Thanks again but it is asking number
[admin@ROUTER] > /ip firewall address-list remove
numbers:
The issue is command scope.
If you run the command under “/” (command root scope) find will run there.
You either need to specify scope, or enter the “/ip firewall address-list” scope.
/ip firewall address-list remove [/ip firewall address-list find list=list_name]
Or
/ip firewall address-list
remove [find list=list_name]
As lines in script?:
/ip firewall address-list
do: { remove [find] } on-error={}
You don’t need to do error handling on address list removal.
If you want to remove ALL entries rather than just entries from a single list, simply do:
/ip firewall address-list remove [/ip firewall address-list find]
or
/ip firewall address-list
remove [find]
Last command seems work better but some entries are not deleted.
I did a video: https://gfycat.com/bravewealthygermanpinscher
This is because you have some dns-based entried in your list.
These create dynamic address-list entries that normally can’t be deleted.
Here is a command that takes that into account:
/ip firewall address-list
remove [find dynamic=no]
Dynamic entries are automatically deleted when their “parent” dns-based entry is deleted.
That should sort it out for you.
IT WORKS!
I’ve used this command on a single line
/ip firewall address-list remove [find dynamic=no]
It delete ALL 1200 address list (even dynamic) without any error.
Thanks!!
For a single line you need to use
/ip firewall address-list remove [/ip firewall address-list find dynamic=no]
Otherwise this will not work if you execute it from root context “/”.
I’ve used
/ip firewall address-list remove [find dynamic=no]
from / context and it worked good.