The if-match ip command sets a matching rule that is based on IP information.
The undo if-match ip command cancels the configuration.
By default, no matching rule based on IP information is set.
if-match ip { next-hop | route-source | group-address } { acl acl-number | ip-prefix ip-prefix-name }
undo if-match ip { next-hop | route-source | group-address } [ acl acl-number | ip-prefix ip-prefix-name ]
| Parameter | Description | Value |
|---|---|---|
| next-hop | Matches the next hop address. | - |
| route-source | Matches the source address of the advertised routes. | - |
| group-address | Specifies the multicast group address. | - |
| acl | Specifies the ACL for route filtering. | - |
| acl-number | Specifies the number of a basic ACL. | It is an integer ranging from 2000 to 2999. |
| ip-prefix ip-prefix-name | Specifies the name of the IP prefix list. | The name is a string of 1 to 169 case-sensitive characters, with spaces not supported. When double quotation marks are used around the string, spaces are allowed in the string. |
Usage Scenario
The if-match ip command is widely applied. The matching rule configured through this command takes effect only after an IP prefix or an ACL is configured. For example:
If the if-match ip next-hop ip-prefix p1 command is used but the IP prefix p1 is not configured, all routes are permitted. This is the same case when the ACL is used.
If the if-match ip next-hop ip-prefix p1 command is used after the ip ip-prefix p1 permit 1.1.1.1 32 command is used, the routes with the next hop address being 1.1.1.1 are permitted. This is the same case when the ACL is used.
Prerequisites
The if-match ip command can be used only after the route-policy command is used.
Before using the if-match ip command, you must run the acl command to configure an ACL or run the ip ip-prefix command to configure an IP prefix.
Configuration Impact
When you filter routes based on the next hop addresses or source addresses, the routes that match the matching rule are permitted and the route that does not match the matching rule are denied.
Precautions
If the next hop address or source address of a route to be filtered is 0.0.0.0, by default, the system considers the mask length as 0 and matches the route.
If the next hop address or source address of a route to be filtered is not 0.0.0.0, by default, the system considers the mask length as 32 and matches the route.
Creating an ACL before it is referenced is recommended. If a nonexistent ACL is referenced using the command, all routes match the ACL.
Creating an IP prefix list before it is referenced is recommended. By default, nonexistent IP prefix lists cannot be referenced using the command. If the route-policy nonexistent-config-check disable command is run in the system view and a nonexistent IP prefix list is referenced using the current command, all routes match the IP prefix list.
# Define a rule to match the routes with the next hop address in the IP prefix list named p1.
<sysname> system-view
[sysname] route-policy policy permit node 10
[sysname-route-policy] if-match ip next-hop ip-prefix p1
# Define a rule to match the routes with the source address matching ACL 2000.
<sysname> system-view
[sysname] route-policy policy permit node 10
[sysname-route-policy] if-match ip route-source acl 2000