Applying Routing Policies and Policy Chains to Routing Protocols
For a routing policy to take effect, you must apply it to either a routing protocol or the forwarding table.
Before applying routing policies to routing protocols, you must know if each protocol supports import and export policies and the level at which you can apply these policies. Protocols That Can Be Imported to and Exported from the Routing Table summarizes the import and export policy support for each routing protocol and the level at which you can apply these policies.
For more information about applying routing policies to individual routing protocols, see the Junos Routing Protocols Configuration Guide.
To apply one or more routing policies to a routing protocol, include the import and export statements:
You can include the statements at the following hierarchy levels:
- [edit protocols protocol-name]
- [edit logical-systems logical-system-name protocols protocol-name]
An ordered set of policies is referred to as a policy chain.
In the import statement, list the names of one or more routing policies to be evaluated when routes are imported into the routing table from the routing protocol.
In the export statement, list the names of one or more routing policies to be evaluated when routes are being exported from the routing table into a dynamic routing protocol. Only active routes are exported from the routing table.
You can reference the same routing policy one or more times in the same or different import and export statements.
The policy framework software evaluates the routing policies in a chain sequentially, from left to right. If an action specified in one of the policies manipulates a route characteristic, the policy framework software carries the new route characteristic forward during the evaluation of the remaining policies. For example, if the action specified in the first policy of a chain sets a route’s metric to 500, this route matches the criterion of metric 500 defined in the next policy.
For information about how the policy framework software evaluates routing policies and policy chains, see Evaluating a Routing Policy.
Effect of Omitting Ingress Match Conditions from Export Policies
In export policies, omitting the from statement in a term might lead to unexpected results. By default, if you omit the from statement, all routes are considered to match. For example, static and direct routes are not exported by BGP by default. However, if you create a term with an empty from statement, these routes inadvertently could be exported because they matched the from statement. For example, the following routing policy is designed to reject a few route ranges and then export routes learned by BGP (which is the default export behavior):
However, this routing policy results in BGP advertising static and direct routes to its peers because:
- term1 rejects the destination prefixes enumerated in the route list.
- term2, because it has no from statement, matches all other routes, including static and direct routes, and accepts all these routes (with the accept statement).
To modify the preceding routing policy so that an IGP does not export unwanted routes, you can specify the following additional terms:
