I’m trying do a script then i can get all the ip’s of the client’s and aply a firewall, the clients make part of a parent, this parent also have a ip, but this ip doesn’t have apply a firewall.
How can i get all the ip of the cliente.
I know how to the a ip of a specific cliente:
:global a [/queue simple get User target-addresses]
:put $a
[/ip firewall filter add chain=forward src-address=$a action=accept]
This script take the ip of a queue and put in the screen and apply a firewall
I need urgently a scrip that do this with all queues.
add another check - run through all firewall filters, search for specific src-address. If rule with that address is already added then do nothing, otherwise add.
tostr converts ip address to string (not necessary in this case but script will work anyway)
Queu taget-address contains netmask (for example “1.1.1.1/32”), but src-address in firewall is not allowing to add ip addresses with netmasks at the end. So that is waht I am doing - removing netmaks.
:foreach n in=[/queue simple find priority=8 parent!=“none”] do={
:local ipnumber [/queue simple get $n target-addresses];
:local comentario [/queue simple get $n name];
:put $comentario;
:if ([:len [/ip firewall filter find comment=$comentario]] = 0) do={
/ip firewall filter add chain=foward src-address=$ipnumber action=accept comment=$comentario;
:log info “A regra de firewall do queue $comentario com ip $ipnumber foi adicionada com sucesso.”;
}
}
This script do some things that i want, bu no all that i need.
Now, i i’m into a very hard problem:
When i go to delete/rename a queue, the rule of firewall created by the script, don’t be removed and don’t remoned, like this:
I go delete a queue, when i deleted this queue, i need that the script verify all the queues, and if exists a firewall rule, that the comment isn’t equal of the queue name, the script remove the queue, that do the same thing if a queue is renamed, the script remove the old rule, and after with a scheduler the script create the new queue with new name.