ip as-path-filter

Function

The ip as-path-filter command adds an AS_Path filter.

The undo ip as-path-filter command deletes a specified AS_Path filter.

By default, no AS_Path filter exists.

Format

ip as-path-filter { as-path-filter-number | as-path-filter-name } [ index index-number ] matchMode regular-expression

undo ip as-path-filter { as-path-filter-number | as-path-filter-name } [ index index-number ] [ matchMode regular-expression ]

Parameters

Parameter Description Value
as-path-filter-number

Specifies the number of an AS_Path filter.

The value is an integer ranging from 1 to 256.

as-path-filter-name

Specifies the name of an AS_Path filter.

The value is a string of 1 to 51 case-sensitive characters, spaces not supported. The character string can contain spaces if it is enclosed in double quotation marks (").

index index-number

Specifies the sequence number of an AS_Path filter.

The value is an integer ranging from 1 to 4294967295.

matchMode

Sets the matching mode of the AS_Path filter.

The value is an enumerated type:

  • deny: Sets the matching mode of the AS_Path filter to deny.
  • permit: Sets the matching mode of the AS_Path filter to permit.
regular-expression

Specifies the AS_Path regular expression.

The value is a string of 1 to 1024 characters, spaces supported.

Views

System view

Default Level

2: Configuration level

Task Name and Operations

Task Name Operations
route-base write

Usage Guidelines

Usage Scenario

An AS_Path filter uses the regular expression to define matching rules. After an AS_Path filter is set, the RM module immediately instructs each protocol to apply the filter by default.

The AS_Path attribute is a private attribute of BGP and is mainly used to filter BGP routes.

  • The AS_Path attribute can be directly applied using a command, such as the peer as-path-filter command.
  • The AS_Path attribute can be configured as a matching condition for a route-policy using a command, such as the if-match as-path-filter zz command.

Configuration Impact

Multiple rules (in permit or deny mode) can be specified for a filter.

Follow-up Procedure

To view detailed configurations of an AS_Path filter, run the display ip as-path-filter command.

Precautions

By default, AS_Path filters work in deny mode. If all matching rules in a filter are configured to work in deny mode, all routes are denied by the filter; to prevent this problem, configure one matching rule in permit mode after one or multiple matching rules in deny mode so that the routes except for those denied by preceding matching rules are permitted by the filter.

The AS number in regular expression of AS-path should be the same with 4-byte as-notation format of BGP, otherwise match will fail.

Example

# Create an AS_Path filter with sequence number 2 to permit the routes that contain 20 in the AS path.
<HUAWEI> system-view
[~HUAWEI] ip as-path-filter 2 permit _20_
# Create an AS_Path filter with sequence number 3 to deny the routes that contain 30 in the AS path.
<HUAWEI> system-view
[~HUAWEI] ip as-path-filter 3 deny _30_
[*HUAWEI] ip as-path-filter 3 permit .*
# Create an AS_Path filter with sequence number 1 to permit the routes with the AS_Path beginning with 10.
<HUAWEI> system-view
[~HUAWEI] ip as-path-filter 1 permit ^10_
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >