Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Example: Using AS Path Regular Expressions

An autonomous system (AS) path is a route attribute used by BGP. The AS path is used both for route selection and to prevent potential routing loops. This example shows how to use regular expressions with AS path numbers to locate a set of routes.

Requirements

No special configuration beyond device initialization is required before configuring this example.

Overview

Figure 1 shows several ASs connected through external BGP (EBGP) peering sessions. Each device is generating customer routes within its assigned address space.

Topology

Figure 1 shows the sample network.

Figure 1: BGP Topology AS Regular ExpressionsBGP Topology AS Regular Expressions

The administrators of AS 64516 want to reject all routes originating in AS 64513 and AS 64514. Two AS path regular expressions called orig-in-64513 and orig-in-64514 are created and referenced in a policy called reject-some-routes. The routing policy is then applied as an import policy on Device R6.

CLI Quick Configuration shows the configuration for all of the devices in Figure 1.

The section #configuration488__policy-as-path-regex-st describes the steps on Device R2 and Device R6. Verification shows how to use the aspath-regex option with the show route command on Device R2 to locate routes using regular expressions.

Configuration

CLI Quick Configuration

To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.

Device R1

Device R2

Device R3

Device R4

Device R5

Device R6

Procedure

Step-by-Step Procedure

The following example requires that you navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Use the CLI Editor in Configuration Mode in the Junos OS CLI User Guide.

To configure Device R2:

  1. Configure the device interfaces.

  2. Configure the EBGP connection to Device R1.

  3. Configure the routing policy.

  4. Configure the static routes.

  5. Configure the AS number.

Step-by-Step Procedure

The following example requires that you navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Use the CLI Editor in Configuration Mode in the Junos OS CLI User Guide.

To configure Device R6:

  1. Configure the device interfaces.

  2. Configure the EBGP connection to Device R5.

  3. Configure the routing policy that sends static routes.

  4. Configure the routing policy that rejects certain routes.

  5. Configure the static routes.

  6. Configure the AS number.

Results

From configuration mode, confirm your configuration by entering the show interfaces, show protocols, show policy-options, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.

Device R2

Device R6

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

Verification

Confirm that the configuration is working properly.

Finding Routes on Device R2

Purpose

On Device R2, use the show route aspath-regex command to locate routes using regular expressions.

Action

Look for routes that are originated by Device R6 in AS 64516.

Look for routes that are originated in either AS 64514 or AS 64516.

Look for routes that use AS 64513 as a transit network.

Meaning

The output shows the routing table entries that match the specified AS path regular expressions.

Making Sure That Routes Are Excluded on Device R6

Purpose

On Device R6, use the show route and show route hidden commands to make sure that routes originating from AS 64513 and AS 64514 are excluded from Device R6’s routing table.

Action

Meaning

The output shows that the 10.30.0/22 and 10.40.0/22 routes are rejected on Device R6.