< Home

apply as-path

Function

The apply as-path command replaces the original AS_Path list or add the specified AS number to the original AS_Path list when BGP route selection is adjusted.

The undo apply as-path command cancels the configuration.

By default, the original AS_Path list is not replaced and no AS number is added to the original AS_Path list.

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 Integral AS number The value is an integer ranging from 1 to 4294967295.
as-number-dot AS number in dotted notation 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 AS_Path list. -
overwrite Replaces the AS_Path list with the specified AS number. -
none Clears the AS_Path list. -

Views

Route-policy view

Default Level

2: Configuration level

Usage Guidelines

Usage Scenario

The AS_Path attribute is private BGP attribute. The apply as-path command takes effect only on BGP routes. The AS-Path list records all ASs that a route passes through from the local to the destination in the distance-vector (DV) order. Using the AS_Path attribute prevents routing loops and controls route selection. If multiple routes are destined for the same destination, BGP compares the AS_Path lists of these routes and considers the route with the shortest AS_Path list as the optimal route.

You can use a route-policy to change AS_Path lists to control BGP route selection and determine the data forwarding path. If routes meet the filtering conditions specified by if-match clauses and the matching mode is set to permit, you can use the apply as-path command to set the AS_Path lists of the routes.

Prerequisites

Before running the apply as-path command, you need to configure a route-policy.

Configuration Effects

After this command is configured, the AS_Path list for matched BGP routes will change. Assume that the original AS-Path is (30, 40, 50) and the BGP route matching condition is met. In this case:
  • 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 can not 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.

Precautions

Configuring the apply as-path command directly affects the path that the traffic passes through and may lead to a loop or a route selection error. Exercise caution when using this command.

Example

# Clear the AS_Path list.

<sysname> system-view
[sysname] route-policy policy permit node 20
[sysname-route-policy] apply as-path none overwrite
Warning: The AS-Path lists of routes to which this route-policy is applied will be overwritten. Continue? [Y/N]
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
Next topic >