Juniper Create Routing Policy with Prefix Match Condition

  • by

A route filter is a collection of match prefixes. When we specifying a match prefix, we can specify an exact match with a particular route or a less precise match. You can configure either a common action that applies to the entire list or an action associated with each prefix. Here I just tried to given the information for longer, orlonger, upto and exact match condition. And i am using here policy name “prefixes-match” and term name “1”, this name can be anything.

If you want to collect IP prefixes “longer” than 172.18.20.0/19 in the routing table. Create a filter that identifies the long prefixes, that mean we just want to those prefixes which only is greater than /19
[edit policy-options policy-statement prefixes-match term 1]
# set route-filter 172.18.20.0/19 longer
# set then accept

[If you want to match prefixes from /19 to /30 that is “orlonger“, using this matched it will collect all routes from /19]
[edit policy-options policy-statement prefixes-match term 1]
# set from route-filter 172.18.20.0/19 orlonger
# set then accept

[If you want to match prefixes from /19 to /24. This is “upto“, this matches is most popular for ISP environment, because global internet router allow upto /24 routes. using this policy it will allowed from /19 prefixes to /24 prefixes; for example  172.18.20.0/19, 172.18.20.0/18, and so on, up to 172.18.20.0/24 ]
[edit policy-options policy-statement prefixes-match term 1]
# set route-filter 172.18.20.0/19 upto /24
# set then accept

This match condition is “prefix-length-range“, which is can only allow the range between /25 to /30 as per bellow configuration. The bellow command matches IP prefixes in the range 0.0.0.0/25, 0.0.0.0/26, 0.0.0.0/27, 0.0.0.0/28, 0.0.0.0/29, and 0.0.0.0/30 only:
[edit policy-options policy-statement prefixes-match term 1]
# set route-filter 0.0.0.0/0 prefix-length-range /25-/30
# set then accept

Route lists can also match exactly one prefix, just as prefix lists can. If you want to match prefixe exactly what you want, then use the match condition to “exact“. This command matches exactly the prefix 172.18.20.0/24.
[edit policy-options policy-statement prefixes-match term 1 ]
# set route-filter 172.18.20.0/24 exact
# set then accept

When you create a policy you must apply it to your configured protocol. Because you create a policy and you must call this policy to your routing protocol, like:
# set protocols bgp group external-group import prefixes-match

Leave a Reply