routes to address list

Hi to All!
Who can help me solve my issue!
Is there any way to add subnets received via BGP into one address-list?
I’ve tried like:
/ip firewall address-list add address=[/ip route find where bgp] list BGP
no results.
Thanks!

Haven’t you forgot one equal sign after “list” keyword ?

/ip firewall address-list add address=[/ip route find where bgp] list=BGP

failure: *440761e1;*4407b265;4406f747;



;*4407
51bb is not a valid dns name

This is not going to work because you are trying to add strng of internal IDs as address not the prefix from the routing table.

:foreach i in=[/ip route find where bgp] do={
  /ip firewall address-list add address=[/ip route get $i dst-address] list=bgp
}

Thanks a lot!!!
Works perfect!
Can you please suggest me, can I create an scheduler and run this script every day for example?

Hi again! One one of my routers I can get next output:
[user@R1] > foreach i in=[/ip route find where bgp] do={/ip firewall address-list add ad
dress=[/ip route get $i dst-address] list=BGP}
failure: already have such entry
[user@R1] > ip fir address-list print where list=BGP
Flags: X - disabled, D - dynamic

LIST ADDRESS TIMEOUT

0 BGP 0.0.0.0/0
[user@R1] >
can this be output because of multi-homing, and same routes are received from 2 different peers? Can I exclude 0.0.0.0/0 adding to this list?
Thank you very much!

I have router OS 6.39.3


I see this error


failure: already have such entry