Writing filters that detect intersection between a prefix and a prefix set

zx at zxinc.org zx at zxinc.org
Tue Dec 16 03:32:53 CET 2025


Hello,

The mask range works magically! Thank you very much!



zx
 
From: Alexander Zubkov
Date: 2025-12-09 03:11
To: zx at zxinc.org
CC: bird-users
Subject: Re: Writing filters that detect intersection between a prefix and a prefix set
Hello,

If you want to match any prefix that intersects (less or more specific) with some prefix of interest - you can use a prefix set like:
  define filter1 = [ 192.168.1.0/24{0,32}, 192.168.2.0/24{0,32} ];
I.e. you need to set the mask range from minimum to maximum - from 0 to 32.

Then you can accept or reject depending on the match result. For example:
  if net ~ filter1 then reject;

Regards,
Alexander

On Sat, Dec 6, 2025 at 6:42 AM zx at zxinc.org <zx at zxinc.org> wrote:
Hello,

I have a prefix set like [ 192.168.1.0/24+, 192.168.2.0/24+ ] and I want to write a filter that
filters all prefixes intersects with the prefix set and accepts all others, that is,
accepts 192.168.0.0/24, 192.168.3.0/24, 10.0.0.0/8,
rejects 192.168.1.1/32, 192.168.1.0/24, 192.168.2.0/24, 192.168.2.0/23, 192.168.0.0/16, 192.0.0.0/8,

Anyone who knows how to write such a filter? Is it possible?

Thanks.

----
zx

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20251216/ef3ef4ee/attachment.htm>


More information about the Bird-users mailing list