Related Documentation
- J Series
- Routing Policies Configuration Overview
- Prepending AS Numbers to BGP AS Paths
- M Series
- Routing Policies Configuration Overview
- Prepending AS Numbers to BGP AS Paths
- MX Series
- Prepending AS Numbers to BGP AS Paths
- QFX Series
- Prepending AS Numbers to BGP AS Paths
- SRX Series
- Routing Policies Configuration Overview
- Prepending AS Numbers to BGP AS Paths
- T Series
- Routing Policies Configuration Overview
- Prepending AS Numbers to BGP AS Paths
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 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.
Step-by-Step Procedure
The following example requires you to navigate various levels in the configuration hierarchy. For instructions on how to do that, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To create a routing policy that prepends AS numbers to multiple routes:
Create the routing policy conditions.
[edit policy-options policy-statement prependpolicy1 term prependterm1]user@R2# set from route-filter 172.16.0.0/12 orlonger user@R2# set from route-filter 192.168.0.0/16 orlongerr user@R2# set from route-filter 10.0.0.0/8 orlongerCreate the routing policy actions, including the AS number to prepend.
[edit policy-options policy-statement prependpolicy1]user@R2# set then as-path-prepend 200 user@R2# set then accept
Note: If you enter multiple numbers, you must separate each number with a space. Enclose the numbers in double quotation marks.
Apply the policy as an import policy for all BGP routes in the local routing table.
Apply the policy as an export policy for all BGP routes advertised to neighbors.
[edit protocols bgp]user@host# set import prependpolicy1
user@host# set export 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.
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 Are Prepended
Purpose
Verify that the AS path is prepended with the specified AS number.
Action
From operational mode, enter the show route command.
Related Documentation
- J Series
- Routing Policies Configuration Overview
- Prepending AS Numbers to BGP AS Paths
- M Series
- Routing Policies Configuration Overview
- Prepending AS Numbers to BGP AS Paths
- MX Series
- Prepending AS Numbers to BGP AS Paths
- QFX Series
- Prepending AS Numbers to BGP AS Paths
- SRX Series
- Routing Policies Configuration Overview
- Prepending AS Numbers to BGP AS Paths
- T Series
- Routing Policies Configuration Overview
- Prepending AS Numbers to BGP AS Paths