Need help in code

Hi!
Im trying to compare two address lists and delete match entries… My code look like this:

:local blackIP
:local visitedIP

:foreach i in=[/ip firewall address-list find list=blocked] do={
  :set blackIP [/ip firewall address-list get $i address]
  :foreach j in=[/ip firewall address-list find list=block_visited] do={
     :set visitedIP [/ip firewall address-list get $j address]
     :if ($blackIP=$visitedIP) do={/ip firewall address-list find list=blocked{
     remove [find address=$blackIP]
             }
         } 
    }
 }

It compares, it find matches, BUT dont delete the record… whats wrong here? :slight_smile:

really? No one knows???

This part doesnt look right
:if ($blackIP=$visitedIP) do={/ip firewall address-list find list=blocked{
remove [find address=$blackIP]
}
}


Should be something like
:if ($blackIP=$visitedIP) do={
/ip firewall address-list remove [find address=$blackIP];
}

Hi, thanks for answer, but - if I have 2 exact addresses, but in different address-lists - this will delete both, isnt?

SOLVED!!!
Correct code:

:local blackIP
:local visitedIP

:foreach i in=[/ip firewall address-list find list=blocked] do={
  :set blackIP [/ip firewall address-list get $i address]
  :foreach j in=[/ip firewall address-list find list=block_visited] do={
     :set visitedIP [/ip firewall address-list get $j address]
     :if ($blackIP=$visitedIP) do={
            /ip firewall address-list remove [find list=blocked address=$blackIP];
            }
       } 
    }
 }

Thanks for help!

Actually you do not need to run find again, since $i already contains needed id to remove address
So you can just:

/ip firewall address-list remove $i

Even better :slight_smile:

And one more question, from different opera: firewall filter can read data (address list) only from section “address list” or there is some way to force it to read data directly from file? (I dont like long address lists in direct view)?

No, firewall cannot read address list from file