Example: Configuring a Routing Policy to Prepend the AS Path

This example shows how to configure a routing policy to prepend the AS path.

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 prependpolicy1 and a term called prependterm1. The routing policy prepends the AS numbers 1 1 1 1 to routes that are greater than or equal to 172.16.0.0/12, 192.168.0.0/16, and 10.0.0.0/8. The policy is applied as an import policy to all BGP routes and is evaluated when routes are imported to the routing table.

Configuration

CLI Quick Configuration

To quickly group source and destination prefixes in a forwarding class, copy the following commands and paste them into the CLI.

[edit]set policy-options policy-statement prependpolicy1 term prependterm1 from route-filter 172.16.0.0/12 orlonger set policy-options policy-statement prependpolicy1 term prependterm1 from route-filter 192.168.0.0/16 orlonger set policy-options policy-statement prependpolicy1 term prependterm1 from route-filter 10.0.0.0/8 orlonger set policy-options policy-statement prependpolicy1 term prependterm1 then as-path-prepend "1 1 1 1" set policy-options policy-statement test term 1 from protocol direct set protocols bgp import prependpolicy1

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 create a routing policy that prepends AS numbers to multiple routes:

  1. Create the routing policy.

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

    [edit policy-options policy-statement prependpolicy1]user@host# edit term prependterm1
  3. Specify the routes to prepend with AS numbers.

    [edit policy-options policy-statement prependpolicy1 term prependterm1]user@host# set from route-filter 172.16.0.0/12 orlongeruser@host# set from route-filter 192.168.0.0/16 orlongeruser@host# set from route-filter 10.0.0.0/8 orlonger
  4. Specify the AS numbers to prepend.

    [edit policy-options policy-statement prependpolicy1 term prependterm1]user@host# set then as-path-prepend “1 1 1 1”

    Note: If you enter multiple numbers, you must separate each number with a space. Enclose the numbers in double quotation marks.

  5. Apply the policy as an import policy for all BGP routes.

    [edit]user@host# set protocols bgp import prependpolicy1

    Note: You can refer to the same routing policy one or more times in the same or different import statement.

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 prependpolicy1 {term prependterm1 {from {route-filter 172.16.0.0/12 orlonger;route-filter 192.168.0.0/16 orlonger;route-filter 10.0.0.0/8 orlonger;}then as-path-prepend "1 1 1 1";}}
user@host# show protocols bgpimport prependpolicy1;

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 AS Numbers to Prepend

Purpose

Verify that the policy and term are configured on the device and that the appropriate routes are specified to prepend with AS numbers.

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