You can use routing policy to filter routes. You do this with route lists, which allow you to evaluate and process routes quickly. Using route lists, you can match groups of routes and then perform a common action on them, or you can perform an action on each individual route immediately.
To specify route prefixes in policies, include one or more route-filter options in the from statement of the policy-statement statement:
[edit]
policy-options {
policy-statement policy-name {
term term-name {
from {
match-conditions;
route-filter destination-prefix match-type <actions>;
prefix-list name;
}
to {
match-conditions;
}
then actions;
}
prefix-list name {
ip-addresses;
}
}
destination-prefix is the IP prefix specified as prefix/prefix-length. If you omit prefix-length, the default is /32.
match-type is the type of match to apply to the destination prefix. It can be one of the match types listed in Table 6. For examples of using the match types, see Examples: Specify Route Lists in Policies.
prefix-list name is the name of a list of IP address prefixes. For information on creating a named list of IP address prefixes, see Define a List of IP Address Prefixes.
actions is the action to take if the destination prefix matches. It can be one or more of the actions listed in Table 3 and Table 4.
In route lists, you can specify actions in two ways:
route-filter option--These action are taken immediately, and the then statement in the policy term is not evaluated.
then statement--These actions are taken after all the routes in the list are evaluated.
To determine whether a route matches a prefix in the route list, all the prefixes in the route list are examined and a longest-match lookup is performed. (The order of different prefixes within the route list is not significant.) If a match occurs, the action associated with that prefix is taken. If the lookup does not yield a match, the policy term does not match the route.
|
|
Within a route list, you can configure the same destination prefix multiple times. In this case, the order of the prefixes is important, because the list of identical prefixes is searched linearly, and the first match type that matches the candidate route applies. In the following example, different match types are specified on the same prefix. The route 0.0.0.0/0 would be rejected, while the route 0.0.0.0/8 would be marked with next-hop self.
0.0.0.0/0 exact reject; 0.0.0.0/0 longer next-hop self;