Hi. I need script to remove ip’s from address list if IP isn’t assigned to any active ppp session. How to write this loop?
I tried that, but it doesn’t work.
:foreach ip in=[/ip firewall address-list find] do {
:foreach ip2 in=[/ppp active find] do {
:if ($ip != ip2) do={/ip firewall address-list [:find address=$ip2}
}
}
Try this:
/ip firewall address-list
:foreach ip in=[find] do={
:if ([:len [/ppp active find address=[get $ip address]]] = 0) do={
remove [find address=[get $ip address]]
}
}
Thank you. But id doesn’t work.
Try this instead. Problem with the previous code I explained here in your other post.
/ip firewall address-list
:foreach ip in=[find] do={
:local add [get $ip address]
:if ([:len [/ppp active find address=$add]] = 0) do={
remove $ip
}
}HTH
Thank you.