The ip ip-prefix command configures an IP prefix list or one entry in the IP prefix list.
The undo ip ip-prefix command deletes an IP prefix list or one entry in the IP prefix list.
By default, no IP prefix list is configured.
ip ip-prefix ip-prefix-name [ index index-number ] matchMode ipv4-address masklen [ match-network ] [ greater-equal greater-equal-value ] [ less-equal less-equal-value ]
undo ip ip-prefix ip-prefix-name [ index index-number ]
undo ip ip-prefix ip-prefix-name ipv4-address masklen [ match-network ] [ greater-equal greater-equal-value ] [ less-equal less-equal-value ]
Parameter | Description | Value |
---|---|---|
ip-prefix-name |
Specifies the name of an 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. |
index index-number |
Specifies the sequence number of the entry in the IP prefix list. |
The value is an integer ranging from 1 to 4294967295. By default, the sequence number increases with a step of 10 according to the configuration order, and the first number is 10. |
matchMode |
Specifies the matching mode of the IP prefix list. |
The value is an enumerated type:
|
ipv4-address |
Specifies the IP address. |
The value is in dotted decimal notation. |
masklen |
Specifies the mask length. |
The value is an integer ranging from 0 to 32. |
match-network |
Specifies to match the network address. match-network is used to filter routes to a specified IP address and can be configured only when ipv4-address is 0.0.0.0. For example, the ip ip-prefix prefix1 permit 0.0.0.0 8 command filters all routes with mask length 8, whereas the ip ip-prefix prefix1 permit 0.0.0.0 8 match-network command filters all routes to the IP address range from 0.0.0.1 to 0.255.255.255. |
- |
greater-equal greater-equal-value |
Specifies the minimum value of the mask length range. |
The value of greater-equal-value is subject to the following rule: masklen<=greater-equal-value<=less-equal-value<=32. |
less-equal less-equal-value |
Specifies the maximum value of the mask length range. |
The value of less-equal-value is subject to the following rule: masklen<=greater-equal-value<=less-equal-value<=32. |
Usage Scenario
An IP prefix list can be used as a filter or as filtering conditions of a route-policy when it is used with the if-match command.
Each entry in an IP prefix list can be used as a filtering rule. When a route to be filtered matches an entry, whether the route matches the IP prefix list is determined by the matching mode. A route to be filtered matches an entry or entries based on the following rules:Configuration Impact
If you create an entry whose <producer-pid> has existed in the same IP prefix list but has different filtering rules, the new entry overwrites the existing one.
Precautions
Because of the matching failure by default, if one or more than one entry with deny as the matching mode is created, create an entry using the ip ip-prefix ip-prefix-name [ index index-number ] permit 0.0.0.0 0 less-equal 32 command so that all IPv4 routes may match the IP prefix list.
If ipv4-address mask-length is specified as 0.0.0.0 0, only default routes are matched. If ipv4-address mask-length is set to 0.0.0.0 0 less-equal 32, all routes are matched. The IP prefix lists in use cannot be deleted. After a configuration is delivered, the device checks the validity of the parameters in the configuration and processes these parameters. After the processing, the generated configuration is the result of the AND calculation between the specified ipv4-address and mask-length. For example, if the specified ipv4-address and mask-length are 1.1.1.1 and 24, respectively, the generated configuration is 1.1.1.0 24. If the ipv4-address in the generated configuration is 0.0.0.0, the configuration matches all IPv4 addresses.<HUAWEI> system-view [~HUAWEI] ip ip-prefix p3 index 10 deny 0.0.0.0 8 match-network [*HUAWEI] ip ip-prefix p3 index 20 permit 0.0.0.0 0 less-equal 32
<HUAWEI> system-view [~HUAWEI] ip ip-prefix p1 permit 10.0.0.0 8 greater-equal 17 less-equal 18
<HUAWEI> system-view [~HUAWEI] ip ip-prefix p2 permit 0.0.0.0 0 greater-equal 17 less-equal 18