apply as-path
Function
The apply as-path command sets the action for changing the AS_Path attribute of BGP routes in a routing policy.
The undo apply as-path command restores the default setting.
By default, the action for changing the AS_Path attribute of BGP routes is not set in a routing policy.
Format
apply as-path { { as-number-plain | as-number-dot } &<1-10> { additive | overwrite } | none overwrite }
undo apply as-path
Parameters
Parameter | Description | Value |
---|---|---|
as-number-plain | Specifies an integral AS number to be added to the AS_Path list or to replace the existing AS_Path list. A maximum of 10 AS numbers can be specified in one command. | The value is an integer ranging from 1 to 4294967295. |
as-number-dot | Specifies an AS number in dotted notation to be added to the AS_Path list or to replace the existing AS_Path list. A maximum of 10 AS numbers can be specified in one command. | The value is in the format of x.y, where x and y are integers that range from 1 to 65535 and from 0 to 65535, respectively. |
additive | Adds the specified AS number to the original AS_Path attribute. | - |
overwrite | Replaces the original AS_Path with the specified AS number. | - |
none | Clears the original AS_Path list. | - |
Usage Guidelines
Usage Scenario
To change the AS_Path attribute of BGP routes BGP for selecting the optimal route, you can apply a routing policy containing the apply as-path command.
AS_Path is a private attribute of BGP and records all ASs that a route passes through from the local end to the destination address. Using the AS_Path attribute controls route selection and prevents routing loops. If multiple routes are destined for the same destination address, BGP compares the AS_Path lists of these routes and considers the route with the shortest AS_Path list as the optimal route.
- If the apply as-path 60 70 80 additive command is run, the AS-Path list is changed to (60, 70, 80, 30, 40, 50). This configuration change is generally used to make the BGP route not preferentially selected.
- If the apply as-path 60 70 80 overwrite command is run, the AS-Path list is changed to (60, 70, 80). There are many application scenarios for changing the AS-Path list, and the major application scenarios are as follows:
- Hide the real path information of routes. For example, after the AS-Path list is changed to (60, 70, 80), the AS-Path information of the route (30, 40, 50) is lost.
- Implement load balancing. For example, a router receives two routes with the same destination IP address 10.1.0.0/16. The AS_Path list of one route is (60, 70, 80) and that of the other route is (30, 40, 50). In this case, you can change the AS_Path list (30, 40, 50) to (60, 70, 80), and load balancing then may be implemented on the two routes.
- Shorten the AS-Path list to prevent the route from being discarded. If the as-path-limit command is configured, whether the number of AS numbers in the AS-Path list of the incoming route exceeds the maximum value needs to be checked. If the number exceeds the maximum value, the route is discarded. Therefore, before receiving a route with a long AS-Path list, replace the AS-Path list with a shorter AS-Path list. For example, if the original AS-Path list is (60, 70, 80, 65001, 65002, 65003), run the apply as-path 60 70 80 overwrite command to change the AS-Path list to (60, 70, 80). In this manner, the length of the AS-Path is shortened, preventing the route from being discarded.
- Shorten the AS-Path list to make the route preferentially selected and traffic directed to the local AS.
- If the apply as-path none overwrite command is run, the AS-Path list is changed to be vacant. In BGP route selection, if the AS-Path list is vacant, the length of the AS-Path list is considered as 0. Therefore, clearing the AS-Path list cannot only hide the real path information, but also make the route preferentially selected and traffic directed to the local AS because the AS-Path list is shortened.
Prerequisites
The apply as-path command can be used only after the route-policy command is used.
Precautions
When a routing policy takes effect, it affects BGP route selection.
Running the apply as-path command changes the path through which network traffic passes. Use this command only when you are familiar with the network topology and impact of the command on services.