<div dir="auto"><div>What are you using the prefix set for in the first place?<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 11, 2023, 2:34 AM William <<a href="mailto:bird@is.unlawful.id.au">bird@is.unlawful.id.au</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 10/05/2023 19:46, Maria Matejka via Bird-users wrote:<br>
> Hello!<br>
<br>
Thanks for replying.<br>
<br>
> On 5/10/23 11:13, William wrote:<br>
>> Hi All,<br>
>> I've been digging around trying to find a nice way of doing it but <br>
>> can't seem to find a valid answer.<br>
>> <br>
>> Is there a way to use a prefix set to create static routes?<br>
> <br>
> No, this is not possible and implementing this would be surprisingly<br>
> difficult as the prefix sets are implemented as a compressed trie<br>
> optimized for fast lookup and not enumeration.<br>
> <br>
> Also imagine this:<br>
> <br>
> define my_route_set = [ 2001:db8/32+ ]; # note the plus sign<br>
> protocol static { ipv6; route my_route_set via 2001:db8::dead:beef; }<br>
> <br>
> This short code would generate approx. 7.9e28 routes.<br>
<br>
Yeah, that could hurt.<br>
<br>
> <br>
> If you could elaborate more precisely what you are trying to achieve<br>
> as a whole result, we may try to help you find how to do it in the way<br>
> BIRD is designed.<br>
<br>
We have a number of remote sites where there are non-dynamically routed <br>
downstream subnets that we need to add as static routes (anything from 1 <br>
to 20+ per site) but also advertise upstream back into the WAN.<br>
<br>
Instead of specifying each prefix as an individual static route I was <br>
hoping to be able to use the existing prefix set to act as a list of <br>
routes to add. If there was a way to iterate over the set in a loop <br>
fashion then that would suffice. In our instance there aren't modifiers <br>
on the masks (no -'s, +'s or {minlen, maxlen}) hence the idea of being <br>
able to use the set as "just a list" - this could be a condition of <br>
using it for that function.<br>
<br>
For example (twist on my original):<br>
<br>
define my_route_set = [ <a href="http://10.1.2.3/24" rel="noreferrer noreferrer" target="_blank">10.1.2.3/24</a>, <a href="http://172.20.4.2/24" rel="noreferrer noreferrer" target="_blank">172.20.4.2/24</a>, <a href="http://10.200.0.0/23" rel="noreferrer noreferrer" target="_blank">10.200.0.0/23</a> ];<br>
<br>
protocol static route_set {<br>
ipv4 {<br>
table Some_Routes;<br>
}<br>
for ThisRoute in my_route_set {<br>
route ThisRoute via 192.168.55.2; # downstream static gateway<br>
}<br>
route <a href="http://5.6.7.8/32" rel="noreferrer noreferrer" target="_blank">5.6.7.8/32</a> via 192.168.55.1;<br>
}<br>
<br>
Resulting in:<br>
bird> sh route table Some_Routes<br>
Table Some_Routes:<br>
<a href="http://10.1.2.3/24" rel="noreferrer noreferrer" target="_blank">10.1.2.3/24</a> unicast [route_set 2023-05-10] * (200)<br>
via 192.168.55.2 on ens256<br>
<a href="http://10.20.4.2/24" rel="noreferrer noreferrer" target="_blank">10.20.4.2/24</a> unicast [route_set 2023-05-10] * (200)<br>
via 192.168.55.2 on ens256<br>
<a href="http://10.200.0.0/23" rel="noreferrer noreferrer" target="_blank">10.200.0.0/23</a> unicast [route_set 2023-05-10] * (200)<br>
via 192.168.55.2 on ens256<br>
<a href="http://5.6.7.8/32" rel="noreferrer noreferrer" target="_blank">5.6.7.8/32</a> unicast [route_set 2023-05-10] * (200)<br>
via 192.168.55.1 on ens256<br>
<a href="http://192.168.55.0/24" rel="noreferrer noreferrer" target="_blank">192.168.55.0/24</a> unicast [Local_Ints 2023-05-10] * (240)<br>
dev ens256<br>
bird><br>
<br>
Hope that explains better what I'm hoping to achieve. I couldn't see a <br>
way of doing it with if..then..else or case statements. The only other <br>
option would be to have a script scrape the set out of the config and <br>
prepare an include file *shudder*.<br>
<br>
Regards,<br>
William<br>
</blockquote></div></div></div>