How to Apply Routing Policies to a Protocol Using Junos - dummies

How to Apply Routing Policies to a Protocol Using Junos

By Walter J. Goralski, Cathy Gadecki, Michael Bushong

Routing policies are the constructs designed by administrators to control what goes into and what comes out of the routing table. That is, routing policies act as an inbound filter into the routing table and ultimately determine what information your router shares with other routers through outbound router advertisements.

  • Policies are associated with routing protocols.

  • Policies control either what is imported into or what is exported out of (advertised from) the routing table.

For example, assume that you want to apply a routing policy to advertise the routes the device learned from BGP with OSPF. (Use this policy carefully! BGP routing tables with all Internet routes can be huge!) Your first policy configuration might look like this:

[edit policy-options]
policy-statement my-sample-policy {
  term my-first-term {
   from protocol bgp;
   then accept;
[edit protocols]
ospf {
  export my-sample-policy;

The policy now begins to take on some meaning. In fact, all policies just sort of sit there until you apply them somehow to a routing protocol. By applying the policy as an export policy for OSPF, you’re saying that you’ll advertise via OSPF all routes learned through BGP.

If the route is not learned via BGP, it is not automatically rejected. If the route doesn’t match the term’s conditions, the route is subjected to the default action. Because the policy is applied to OSPF, the default export behavior is to accept all routes learned via OSPF. This behavior means that an OSPF route, even though it doesn’t match the term, will be accepted because of the default action.

To apply the same policy to explicitly import all received BGP routing information into your routing table, you simply change how the policy is applied:

[edit protocols]
bgp {
  import my-sample-policy;

By changing only how the policy is applied, the entire meaning of the policy is altered.

When you’re creating policies, don’t get too wrapped up in the words “accept” and “reject.” Accept doesn’t necessarily mean that your routing table will be accepting the routes: When applied as an export policy, you’re advertising the routes.

Conversely, reject doesn’t imply that your routing table will be rejecting routes: When applied as an export policy, reject will suppress the route, but not make it disappear from your router. The behavior depends on whether the routing policy is applied on the inbound side (as an import policy) or on the outbound side (as an export policy).