if

Function

The if command configures matching rules for a route-filter.

By default, no matching rules are configured for a route-filter, and all routes match the route-filter.

Format

if [ not ] condition-clause [ { and | or } [ not ] condition-clause ] * then

Parameters

Parameter Description Value
not

Filters routes against the opposite of the matching rule following not.

-

condition-clause

Specifies a condition clause.

For details of condition clauses, see the following descriptions:

  • Condition clause that is based on the route cost
  • Condition clause that is based on the source IP address, destination IP address, or next hop IP address of a route
  • Condition clause that is based on the tag of an OSPF or IS-IS route
  • Condition clause that is based on the Local_Pref attribute of a BGP route
  • Condition clause that is based on the AS_Path attribute of a BGP route
  • Condition clause that is based on the community attribute of a BGP route
  • Condition clause that is based on an attribute of a VPN route
  • Condition clause that is based on any of other attributes
and

Filters routes against the matching rule of the previous condition clause and the one following and.

-

or

Filters routes against the matching rule of the previous condition clause or the one following or.

-

then

Introduces the action clause configured for the routes that meet matching rules.

-

Views

Route-filter policy view

Default Level

2: Configuration level

Task Name and Operations

Task Name Operations
route-base write

Usage Guidelines

Usage Scenario

Route-filters are used to filter routes based on sets or a single element and modify route attributes of the routes that meet matching rules. To configure matching rules for a route-filter, run the if command.

The parameters in condition clauses can be specific values or global variables referenced using $+global variable name. The parameters in a route-filter with pre-defined variables can be those defined in this route-filter.

Global variables cannot be referenced by the route attribute sets in the format of {element A, element B...}.

Follow-up Procedure

Run the apply, approve, refuse, finish, call route-filter, or break command to configure an action for the routes that meet matching rules.

Precautions

The maximum number of nested if clauses is 64. One if clause can connect 32 AND or OR Boolean operators. The keyword NOT can be consecutively nested for a maximum of 4 times.

If ip { route-source | route-destination | next-hop } in { ip-prefix-list-name | ip-prefix-list } is configured, the configuration applies to IPv4 prefixes, not to IPv6 prefixes, and IPv6 prefixes match the configuration by default. If IPv6 prefixes also need to be filtered, perform the following configurations:

xpl ipv6-prefix-list ipv6-list-null

end-list

if ip { route-source | route-destination | next-hop } in { ip-prefix-list-name | ip-prefix-list } then

if ipv6 { route-source | route-destination | next-hop } in ipv6-list-null then

finish

elseif ip { route-source | route-destination | next-hop } in { ip-prefix-list-name | ip-prefix-list } then

apply action-clause

endif

endif

If ipv6 { route-source | route-destination } in { ipv6-prefix-list-name | ipv6-prefix-list } is configured, the configuration applies to IPv6 prefixes, not to IPv4 prefixes, and IPv4 prefixes match the configuration by default. If IPv4 prefixes also need to be filtered, perform the following configurations:

xpl ip-prefix-list ipv4-list-null

end-list

if ipv6 { route-source | route-destination | next-hop } in { ip-prefix-list-name | ip-prefix-list } then

if ip { route-source | route-destination | next-hop } in ipv4-list-null then

finish

elseif ip { route-source | route-destination | next-hop } in { ip-prefix-list-name | ip-prefix-list } then

apply action-clause

endif

endif

Example

# Configure a matching rule for a route-filter to allow only the routes with MED 100 to match the route-filter.
<HUAWEI> system
[~HUAWEI] xpl route-filter route-filter1
[~HUAWEI-xpl-filter] if med eq 100 then
[~HUAWEI-xpl-filter-if] approve
[~HUAWEI-xpl-filter-if] endif
[~HUAWEI-xpl-filter] end-filter
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >