Example: Injecting OSPF Routes into the BGP Routing Table

This example shows you how to create a policy that injects OSPF routes into the BGP routing table.

Requirements

Before you begin, configure router interfaces and configure routing protocols, as explained in Routing Policies Configuration Overview.

Overview

In this example, you create a routing policy called injectpolicy1 and a routing term called injectterm1. The policy injects OSPF routes into the BGP routing table.

Configuration

CLI Quick Configuration

To quickly create a policy that injects OSPF routes into the BGP routing table, copy the following commands and paste them into the CLI.

[edit]set policy-options policy-statement injectpolicy1 term injectterm1 from protocol ospfset policy-options policy-statement injectpolicy1 term injectterm1 from area 0.0.0.1set policy-options policy-statement injectpolicy1 term injectterm1 then acceptset policy-options policy-statement test term 1 from protocol directset protocols bgp export injectpolicy1

Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode.

To inject OSPF routes into a BGP routing table:

  1. Create the routing policy.

    [edit]user@host# edit policy-options policy-statement injectpolicy1
  2. Create the policy term.

    [edit policy-options policy-statement injectpolicy1]user@host# edit term injectterm1
  3. Specify OSPF as a match condition.

    [edit policy-options policy-statement injectpolicy1 term injectterm1]user@host# set from protocol ospf
  4. Specify the routes from an OSPF area as a match condition.

    [edit policy-options policy-statement injectpolicy1 term injectterm1]user@host# set from area 1
  5. Specify that the route is to be accepted if the previous conditions are matched.

    [edit policy-options policy-statement injectpolicy1 term injectterm1]user@host# set then accept
  6. Apply the routing policy to BGP.

    [edit]user@host# set protocols bgp export injectpolicy1

Results

Confirm your configuration by entering the show policy-options and show protocols bgp commands from configuration mode. If the output does not display the intended configuration, repeat the configuration instructions in this example to correct it.

user@host# show policy-optionspolicy-statement injectpolicy1 {term injectterm1 {from {protocol ospf;area 0.0.0.1;}then accept;}}
user@host# show protocols bgpexport injectpolicy1;

If you are done configuring the device, enter commit from configuration mode.

Verification

To confirm that the configuration is working properly, perform these tasks:

Verifying the OSPF-Based Match Conditions

Purpose

Verify that the policy and term are configured on the device with the appropriate OSPF-based match conditions.

Action

From operational mode, enter the show policy-options command.

Verifying the Routing Policy

Purpose

Verify that the routing policy is applied to the routing protocol.

Action

From operational mode, enter the show protocols bgp command.

Related Topics