I'm trying to find the most elegant way to implement a RTBH filter for routes received from a customer.
The filter should:
- Only accept the customers own prefixes from a prefix-list
- Only accept /32 prefixes
- Only prefixes with the blackhole community
- Set the next-hop to the RTBH next-hop (192.0.2.1)
To begin I looked at the "Configuring Match Conditions in Routing Policy Terms" document from Juniper.
First I thought about combining a prefix-list-filter
to only match routes from the customers prefix-list and a route-filter
to limit the accepted prefixes to /32, like so:
from {
as-path customer;
community blackhole;
prefix-list-filter customer-prefixes orlonger;
route-filter 0.0.0.0/0 prefix-length-range /32-/32;
}
But then I stumbled about this information in the document:
If you configure a policy that includes some combination of route filters, prefix lists, and source address filters, they are evaluated according to a logical OR operation or a longest-route match lookup.
As I understand this (and I find it a bit unclear), if I use prefix-list-filter
, route-filter
and/or source-address-filter
in the same term it would be evaluated with a longest-match OR between all of them, which makes this approach unusable.
What I came up with is this the following filter. The hostroutes-only
term diverts all prefixes shorter than /32 to the next policy. After that the prefixes
term matches if the /32 is in the range of the customer, matches his as-path and has the blackhole community set:
term hostroutes-only {
from {
route-filter 0.0.0.0/0 prefix-length-range /0-/31;
}
then next policy;
}
term prefixes {
from {
as-path customer;
community blackhole;
prefix-list-filter customer-prefixes orlonger;
}
then {
next-hop 192.0.2.1;
accept;
}
}
So, is this the most elegant way to handle this? Any other solutions?