- Table of Contents
-
- 05-Layer 3—IP Routing Command Reference
- 00-Preface
- 01-Basic IP routing commands
- 02-Static routing commands
- 03-RIP commands
- 04-OSPF commands
- 05-IS-IS commands
- 06-BGP commands
- 07-Policy-based routing commands
- 08-IPv6 static routing commands
- 09-RIPng commands
- 10-OSPFv3 commands
- 11-IPv6 policy-based routing commands
- 12-Routing policy commands
- 13-DCN commands
- Related Documents
-
Title | Size | Download |
---|---|---|
07-Policy-based routing commands | 117.08 KB |
Contents
apply fail-action-drop next-hop
display ip policy-based-route global
display ip policy-based-route interface
display ip policy-based-route local
display ip policy-based-route setup
ip ignore policy-based-route dest-local enable
reset ip policy-based-route statistics
Policy-based routing commands
apply fail-action-drop next-hop
Use apply fail-action-drop next-hop to set the action that drops matching packets when all next hops on a policy node are invalid.
Use undo apply fail-action-drop next-hop to restore the default.
Syntax
apply fail-action-drop next-hop
undo apply fail-action-drop next-hop
Default
The drop action is not configured. The matching packets are forwarded based on the typical packet forwarding process if all next hops on the policy node are invalid.
Views
Policy node view
Predefined user roles
network-admin
Usage guidelines
By default, the device uses the typical packet forwarding process to route matching packets when all next hops on the policy node are unavailable. To drop all matching packets when all next hops on the policy node are unavailable, use this command. This command is typically used in scenarios that require strict routing paths.
If no next hops are specified on the policy node, this command drops all packets that match the node.
This command does not apply to software-forwarded packets.
Examples
# Set next hop 1.1.1.1 on policy node 10 and configure the policy node to drop matching packets when the next hop is invalid.
<Sysname> system-view
[Sysname] policy-based-route policy1 permit node 10
[Sysname-pbr-policy1-10] apply next-hop 1.1.1.1
[Sysname-pbr-policy1-10] apply fail-action-drop next-hop
apply loadshare
Use apply loadshare to enable load sharing among multiple next hops.
Use undo apply loadshare to restore the default.
Syntax
apply loadshare next-hop
undo apply loadshare next-hop
Default
Multiple next hops operate in primary/backup mode.
Views
Policy node view
Predefined user roles
network-admin
Parameters
next-hop: Enables load sharing among multiple next hops.
Usage guidelines
Multiple next hop options operate in either primary/backup or load sharing mode.
· Primary/backup mode—One option is selected from all options in configuration order for packet forwarding, with all remaining options as backups. For example, if multiple next hops are configured, the first configured next hop is selected. When the selected next hop fails, the next available next hop takes over.
· Load sharing mode—Matching traffic is distributed across the available options. Mulitple next hops load share traffic in round robin manner, starting from the first configured option. They perform per-packet load sharing for traffic that does not match any fast forwarding entry, and perform per-flow load sharing for traffic that matches a fast forwarding entry.
Examples
# Enable load sharing among multiple next hops.
<Sysname> system-view
[Sysname] policy-based-route aa permit node 11
[Sysname-pbr-aa-11] apply next-hop 1.1.1.1 2.2.2.2
[Sysname-pbr-aa-11] apply loadshare next-hop
Related commands
apply next-hop
apply mirror-to-destination
Use apply mirror-to-destination to set a mirroring action that mirrors packets to the specified destination IP address.
Use undo apply mirror-to-destination to restore the default.
Syntax
apply mirror-to-destination [ vpn-instance vpn-instance-name ] destination-ip-address [ source-ip source-ip-address ] [ dscp dscp-value ]
undo apply mirror-to-destination [ vpn-instance vpn-instance-name ] destination-ip-address
Default
The mirroring action is not set.
Views
Policy node view
Predefined user roles
network-admin
Parameters
vpn-instance vpn-instance-name: Specifies an MPLS L3VPN instance to which the destination IP address belongs. The vpn-instance-name argument is a case-sensitive string of 1 to 31 characters. The specified VPN instance must already exist. If the destination IP address belongs to the public network, do not specify this option.
destination-ip-address: Specifies the destination IP address encapsulated in the outer header of mirrored packets.
source-ip source-ip-address: Specifies the source IP address encapsulated in the outer header of mirrored packets. If you do not specify this option, the primary IP address for the output interface of the mirrored packets is encapsulated.
dscp dscp-value: Specifies the DSCP value encapsulated in the outer header of mirrored packets. The value range for the dscp-value argument is 0 to 63, and the default value is 63.
Usage guidelines
This command enables the device to mirror packets to a specific destination device through a tunnel (for example, a GRE tunnel) for packet analysis and monitoring. The device will encapsulate the parameters set for this command in the outer header of the mirrored packets.
This apply clause is always executed for packets matching the policy node.
Examples
# Set a mirroring action by specifying source IP address 2.2.2.2 and destination IP address 1.1.1.1 in the outer header of mirrored packets.
<Sysname> system-view
[Sysname] policy-based-route aa permit node 11
[Sysname-pbr-aa-11] apply mirror-to-destination 1.1.1.1 source-ip 2.2.2.2
apply next-hop
Use apply next-hop to set next hops.
Use undo apply next-hop to remove next hops.
Syntax
apply next-hop [ vpn-instance vpn-instance-name ] { ip-address [ direct ] [ track track-entry-number ] [ service-chain path-id service-path-id [ path-index service-patch-index ] ] }&<1-6>
undo apply next-hop [ [ vpn-instance vpn-instance-name ] ip-address&<1-6> ]
Default
No next hops are set.
Views
Policy node view
Predefined user roles
network-admin
Parameters
vpn-instance vpn-instance-name: Specifies an MPLS L3VPN instance by its name, a case-sensitive string of 1 to 31 characters. The specified VPN instance must already exist.
ip-address: Specifies the IP address of the next hop. If you do not specify the vpn-instance vpn-instance-name option, the next hop belongs to the public network.
direct: Specifies that the next hop must be directly connected to take effect.
track track-entry-number: Specifies a track entry by its number in the range of 1 to 1024.
service-chain path-id service-path-id: Specifies a service chain by its path ID. A path ID uniquely identifies a service chain, and its value range is 1 to 16777215.
path-index service-path-index: Specifies a node in the service chain as a next hop by its index in the range of 1 to 255.
&<1-6>: Indicates that the argument before it can be entered up to six times.
Usage guidelines
You can specify multiple next hops for backup in one command line or by executing this command multiple times.
With a next hop specified, the undo apply next-hop command removes the next hop.
Without any next hop specified, the undo apply next-hop command removes all next hops.
To set multiple next hops and specify their service chain parameters (service chain path ID and node index), follow these guidelines:
· If the next hops are used in different service chains, use the apply next-hop command to specify the service chain parameters.
· If the next hops are used in the same service chain, use the apply service-chain command to specify the service chain parameters as a best practice.
· On a policy node, you cannot configure both the apply next-hop command with the service chain parameters and the apply service-chain command.
Examples
# Set a directly-connected next hop of 1.1.1.1.
<Sysname> system-view
[Sysname] policy-based-route aa permit node 11
[Sysname-pbr-aa-11] apply next-hop 1.1.1.1 direct
apply loadshare
apply service-chain
apply output-interface
Use apply output-interface to set output interfaces.
Use undo apply output-interface to remove output interfaces.
Syntax
apply output-interface null 0
undo apply output-interface [ null 0 ]
Default
No output interfaces are set.
Views
Policy node view
Predefined user roles
network-admin
Parameters
null 0: Specifies the Null 0 interface.
track track-entry-number: Specifies a track entry by its number in the range of 1 to 1024.
Usage guidelines
With an output interface specified, the undo apply output-interface command removes the output interface.
Without any output interface specified, the undo apply output-interface command removes all output interfaces.
Examples
# Specify VLAN-interface 2 as the output interface for IP packets.
<Sysname> system-view
[Sysname] policy-based-route aa permit node 11
[Sysname-pbr-aa-11] apply output-interface vlan-interface 2
apply service-chain
Use apply service-chain to set service chain information.
Use undo apply service-chain to restore the default.
Syntax
apply service-chain path-id service-path-id [ path-index service-path-index ]
undo apply service-chain
Default
No service chain information is set.
Views
Policy node view
Predefined user roles
network-admin
Parameters
path-id service-path-id: Specifies a service chain by its path ID in the range of 1 to 16777215. The path ID uniquely identifies a service chain.
path-index service-path-index: Specifies the path index of the node to which you are sending the matching packets. The value range for path indexes is 1 to 255. Specify this option if the destination node might receive packets from different nodes in the service chain. If the destination node receives packets only from the device, you do not need to specify this option.
Examples
# Set service chain path ID 1 and node index 10.
<Sysname> system-view
[Sysname] policy-based-route aa permit node 5
[Sysname-pbr-aa-5] apply service-chain path-id 1 path-index 10
description
Use description to configure a description for a policy node.
Use undo description to restore the default.
Syntax
description text
undo description
Default
No description is configured for a policy node.
Views
Policy node view
Predefined user roles
network-admin
Parameters
text: Specifies a description, a case-sensitive string of 1 to 127 characters.
Examples
# Configure the description as Officeuse for policy node 1.
<Sysname> system-view
[Sysname] policy-based-route 1 permit node 1
[Sysname-pbr-1-1] description Officeuse
display ip policy-based-route
Use display ip policy-based-route to display PBR policy information.
Syntax
display ip policy-based-route [ policy policy-name ]
Views
Any view
Predefined user roles
network-admin
network-operator
Parameters
policy policy-name: Specifies a policy by its name, a case-sensitive string of 1 to 19 characters. If you do not specify a policy, this command displays information for all PBR policies.
Examples
# Display all policy information.
<Sysname> display ip policy-based-route
Policy name: aaa
node 1 permit:
if-match acl 2000
apply next-hop 1.1.1.1
Table 1 Command output
Field |
Description |
node 1 permit |
The match mode of Node 1 is permit. |
if-match acl |
Compares packets with the ACL. |
apply next-hop |
Specifies a next hop for permitted packets. |
Related commands
policy-based-route
display ip policy-based-route global
Use display ip policy-based-route global to display information about global PBR, including its configuration and statistics.
Syntax
display ip policy-based-route global [ slot slot-number ]
Views
Any view
Predefined user roles
network-admin
network-operator
Parameters
slot slot-number: Specifies an IRF member device by its member ID. If you do not specify a member device, this command displays information about global PBR on the master device.
Examples
# Display information about global PBR.
<Sysname> display ip policy-based-route global
Global policy-based routing information:
Policy name: aaa
node 0 deny:
Matches: 0, bytes: 0
node 1 permit:
if-match acl 3999
Matches: 0, bytes: 0
node 2 permit:
if-match acl 2000
apply next-hop 2.2.2.2
Matches: 0, bytes: 0
node 5 permit:
if-match acl 3101
apply next-hop 1.1.1.1
Matches: 0, bytes: 0
Total matches: 0, total bytes: 0
Table 2 Command output
Field |
Description |
Global policy-based routing information |
Global PBR configuration and statistics. This field displays failed in brackets if none of the nodes in the policy has been successfully issued to the driver. The failed status will persist even after the policy is successfully issued. To clear the failed status, you must remove the policy and then apply it again. |
node 0 deny node 2 permit |
Match mode of the node, permit or deny. If a node fails to be issued to the driver, the command displays the cause in brackets, which include: · not support—The device does not support the match criteria configured on the node. · no resource—No sufficient resources (for example, ACLs) are available for the node. |
if-match acl |
Compares packets with the ACL. |
apply next-hop |
Specifies a next hop for permitted packets. |
apply output-interface XXXX track 1 |
Specifies an output interface for permitted packets. This field displays the interface status in brackets. · down—The interface is down at the network layer. · inactive—The card that hosts the interface is not in position. |
Matches |
Number of successful matches on the node. If the device does not have sufficient resources to count matches, this field displays no statistics resource in brackets. |
bytes |
Number of matching bytes on the node. |
Total matches |
Total number of successful matches on all nodes. |
total bytes |
Total number of matching bytes on all nodes. |
Related commands
ip global policy-based-route
display ip policy-based-route interface
Use display ip policy-based-route interface to display interface PBR configuration and statistics.
Syntax
display ip policy-based-route interface interface-type interface-number [ slot slot-number ]
Views
Any view
Predefined user roles
network-admin
network-operator
Parameters
interface-type interface-number: Specifies an interface by its type and number.
slot slot-number: Specifies an IRF member device by its member ID. If you do not specify a member device, this command displays information on the master device.
Examples
# Display PBR configuration and statistics on VLAN-interface 2.
<Sysname> display ip policy-based-route interface vlan-interface 2
Policy based routing information for interface Vlan-interface2:
Policy name: aaa
node 0 deny:
Matches: 0, bytes: 0
node 1 permit:
if-match acl 3999
Matches: 0, bytes: 0
node 2 permit:
if-match acl 2000
apply next-hop 2.2.2.2
Matches: 0, bytes: 0
node 5 permit:
if-match acl 3101
apply next-hop 1.1.1.1
Matches: 0, bytes: 0
Total matches: 0, total bytes: 0
Table 3 Command output
Field |
Description |
Policy based routing information for interface XXXX |
PBR configuration and statistics on the interface. This field displays failed in brackets if none of the nodes in the policy has been successfully issued to the driver. The failed status will persist even after the policy is successfully issued. To clear the failed status, you must remove the policy from the interface and then apply it on the interface again. NOTE: The failed status is available on a per-slot basis. To obtain this information, you must specify a slot number when you execute the command. · For a global interface (for example, a VLAN interface), which might have member physical interfaces on multiple slots, specify a slot that contains its member interfaces. · For a physical interface, specify its slot number. |
node 0 deny node 2 permit |
Match mode of the node, permit or deny. If a node fails to be issued to the driver, the command displays the cause in brackets, which include: · not support—The device does not support the match criteria configured on the node. · no resource—No sufficient resources (for example, ACLs) are available for the node. NOTE: The cause is available only on a per-slot basis. To obtain this information, you must specify a slot number when you execute the command. · For a global interface (for example, a VLAN interface), which might have member physical interfaces on multiple slots, specify a slot that contains its member interfaces. · For a physical interface, specify its slot number. |
if-match acl |
Compares packets with the ACL. |
apply next-hop |
Specifies a next hop for permitted packets. |
Matches |
Number of successful matches on the node. If the device does not have sufficient resources to count matches, this field displays no statistics resource in brackets. NOTE: The statistics collection failure cause is available only on a per-slot basis. To obtain this information, you must specify a slot number when you execute the command. · For a global interface (for example, a VLAN interface), which might have member physical interfaces on multiple slots, specify a slot that contains its member interfaces. · For a physical interface, specify its slot number. |
bytes |
Number of matching bytes on the node. |
Total matches |
Total number of successful matches on all nodes. |
total bytes |
Total number of matching bytes on all nodes. |
Related commands
ip policy-based-route
display ip policy-based-route local
Use display ip policy-based-route local to display local PBR configuration and statistics.
Syntax
display ip policy-based-route local [ slot slot-number ]
Views
Any view
Predefined user roles
network-admin
network-operator
Parameters
slot slot-number: Specifies an IRF member device by its member ID. If you do not specify a member device, this command displays local PBR configuration and statistics for the master device.
Examples
# Display local PBR configuration and statistics.
<Sysname> display ip policy-based-route local
Policy based routing information for local:
Policy name: aaa
node 0 deny:
Matches: 0, bytes: 0
node 1 permit:
if-match acl 3999
Matches: 0, bytes: 0
node 2 permit:
if-match acl 2000
apply next-hop 2.2.2.2
Matches: 0, bytes: 0
node 5 permit:
if-match acl 3101
apply next-hop 1.1.1.1
Matches: 0, bytes: 0
Total matches: 0, total bytes: 0
Table 4 Command output
Field |
Description |
Policy based routing information for local |
Local PBR configuration and statistics. |
node 0 deny/node 2 permit |
Match mode of the node: permit or deny. |
if-match acl |
Compares packets with the ACL. |
apply next-hop |
Specifies a next hop for permitted packets. |
Matches |
Number of successful matches on the node. |
bytes |
Number of matching bytes on the node. |
Total matches |
Total number of successful matches on all nodes. |
total bytes |
Total number of matching bytes on all nodes. |
Related commands
ip local policy-based-route
display ip policy-based-route setup
Use display ip policy-based-route setup to display PBR configuration.
Syntax
display ip policy-based-route setup
Views
Any view
Predefined user roles
network-admin
network-operator
Examples
# Display PBR configuration.
<Sysname> display ip policy-based-route setup
Policy name Type Interface
pr01 Forward Vlan-interface2
aaa Local N/A
pr01 Global N/A
Table 5 Command output
Field |
Description |
Type |
Type of the PBR: · Forward—Interface PBR. · Local—Local PBR. · Global—Global PBR. |
Interface |
Interface where the policy is applied. This field displays N/A for local PBR and global PBR. |
if-match acl
Use if-match acl to set an ACL match criterion.
Use undo if-match acl to restore the default.
Syntax
if-match acl { acl-number | name acl-name }
undo if-match acl
Default
No ACL match criterion is set.
Views
Policy node view
Predefined user roles
network-admin
Parameters
acl-number: Specifies an ACL by its number in the range of 2000 to 2999 for a basic ACL, and in the range of 3000 to 3999 for an advanced ACL.
name acl-name: Specifies an ACL by its name, a case-insensitive string of 1 to 63 characters starting with letter a to z or A to Z. The ACL name cannot be all. For the command to take effect, make sure the specified ACL is a basic or advanced ACL.
Usage guidelines
If the specified ACL does not exist or has no rules configured, no packets will match the ACL.
If the vpn-instance keyword is specified for an ACL rule, the ACL does not take effect. If the vpn-instance keyword is not specified, the rule applies to both public and private network packets.
Examples
# Configure Node 11 of policy aa to permit the packets matching ACL 2011.
<Sysname> system-view
[Sysname] policy-based-route aa permit node 11
[Sysname-pbr-aa-11] if-match acl 2011
# Configure Node 11 of policy aa to permit the packets matching ACL aaa.
<Sysname> system-view
[Sysname] policy-based-route aa permit node 11
[Sysname-pbr-aa-11] if-match acl name aaa
if-match service-chain
Use if-match service-chain to set a service chain match criterion.
Use undo if-match service-chain to restore the default.
Syntax
if-match service-chain path-id service-path-id [ path-index service-patch-index ]
undo if-match service-chain [ path-id service-path-id ]
Default
No service chain match criteria are set.
Views
Policy node view
Predefined user roles
network-admin
Parameters
path-id service-path-id: Specifies a service chain by its path ID in the range of 1 to 16777215. The path ID uniquely identifies a service chain.
path-index service-path-index: Specifies a node in the service chain by its index to match packets sent from that node. The value range for path indexes is 1 to 255. Specify this option if the device might receive packets from different nodes in the service chain. If only one node in the service chain sends packets to the device, you do not need to specify this option.
Examples
# Set a service chain match criterion to match packets with service chain path ID 1 and node index 10.
<Sysname> system-view
[Sysname] policy-based-route aa permit node 5
[Sysname-pbr-aa-5] if-match service-chain path-id 1 path-index 10
ip global policy-based-route
Use ip global policy-based-route to specify a PBR policy as the global PBR policy.
Use undo ip global policy-based-route to restore the default.
Syntax
ip global policy-based-route policy-name
undo ip global policy-based-route
Default
No policy is specified for global PBR.
Views
System view
Predefined user roles
network-admin
Parameters
policy-name: Specifies a PBR policy by its name, a case-sensitive string of 1 to 19 characters. The specified policy must already exist.
Usage guidelines
Global PBR guides the forwarding of packets on all interfaces of the device.
You can specify only one policy for global PBR on the device. Before you apply a new policy, you must first remove the current policy.
Interface PBR takes precedence over global PBR on an interface. When they are both configured and packets fail to match the interface PBR policy, global PBR applies.
Examples
# Specify PBR policy aaa for global PBR.
<Sysname> system-view
[Sysname] ip global policy-based-route aaa
Related commands
display ip policy-based-route global
ip ignore policy-based-route dest-local enable
Use ip ignore policy-based-route dest-local enable to enable PBR to ignore IPv4 packets destined to the local interface.
Use undo ip ignore policy-based-route dest-local enable to restore the default.
Syntax
ip ignore policy-based-route dest-local enable
undo ip ignore policy-based-route dest-local enable
Default
PBR does not ignore IPv4 packets destined to the local interface.
Views
Interface view
Predefined user roles
network-admin
Usage guidelines
If the device performs forwarding in hardware and a packet destined for it matches a PBR policy, PBR will execute the apply clauses in the policy, including the clause for forwarding. To prevent PBR from mistakenly forwarding the packet to another device, you can configure this command in interface view. Upon receiving a packet destined to any IPv4 addresses (main or secondary) of the interface, the device will ignore PBR settings and deliver the packet to the CPU.
Examples
# Enable PBR to ignore IPv4 packets destined to local interface VLAN-interface 2.
<Sysname> system-view
[Sysname] interface vlan-interface 2
[Sysname-Vlan-interface2] ip ignore policy-based-route dest-local enable
ip local policy-based-route
Use ip local policy-based-route to specify a policy for local PBR.
Use undo ip local policy-based-route to restore the default.
Syntax
ip local policy-based-route policy-name
undo ip local policy-based-route
Default
No policy is specified for local PBR.
Views
System view
Predefined user roles
network-admin
Parameters
policy-name: Specifies a policy by its name, a case-sensitive string of 1 to 19 characters. The specified policy must already exist.
Usage guidelines
Local PBR guides the forwarding of locally generated packets, such as ICMP packets generated by using the ping command.
Local PBR might affect local services, such as ping and Telnet. When you use local PBR, make sure you fully understand its impact on local services of the device.
You can specify only one policy for local PBR and must make sure the specified policy already exists.
Before you apply a new policy, you must first remove the current policy.
Examples
# Configure local PBR based on policy aaa.
<Sysname> system-view
[Sysname] ip local policy-based-route aaa
Related commands
display ip policy-based-route local
ip policy-based-route
Use ip policy-based-route to specify a policy for interface PBR on an interface.
Use undo ip policy-based-route to restore the default.
Syntax
ip policy-based-route policy-name
undo ip policy-based-route
Default
No policy is applied to an interface.
Views
Interface view
Predefined user roles
network-admin
Parameters
policy-name: Specifies a policy by its name, a case-sensitive string of 1 to 19 characters. The specified policy must already exist.
Examples
# Apply policy aaa to VLAN-interface 2.
<Sysname> system-view
[Sysname] interface vlan-interface 2
[Sysname-Vlan-interface2] ip policy-based-route aaa
Related commands
display ip policy-based-route interface
policy-based-route
Use policy-based-route to create a policy node and enter its view, or enter the view of an existing policy node.
Use undo policy-based-route to delete a policy or policy node.
Syntax
policy-based-route policy-name [ deny | permit ] node node-number
undo policy-based-route policy-name [ deny | node node-number | permit ]
Default
No policy nodes exist.
Views
System view
Predefined user roles
network-admin
Parameters
policy-name: Specifies a policy by its name, a case-sensitive string of 1 to 19 characters.
deny: Specifies the match mode for the policy node as deny.
permit: Specifies the match mode for the policy node as permit (default mode).
node node-number: Specifies a policy node by its number. A smaller number has a higher priority. The value range for the node-number argument is 0 to 65535.
Usage guidelines
A policy that has been applied to an interface or locally cannot be deleted. To delete it, you must first cancel the application.
· If a policy node is specified, the undo policy-based-route command deletes the specified policy node.
· If a match mode is specified, the command deletes all nodes configured with the match mode.
· If no policy node or match mode is specified, the command deletes the whole policy.
Examples
# Create permit-mode of Node 10 for policy policy1 and enter its view.
<Sysname> system-view
[Sysname] policy-based-route policy1 permit node 10
[Sysname-pbr-policy1-10]
Related commands
display ip policy-based-route
reset ip policy-based-route statistics
Use reset ip policy-based-route statistics to clear PBR statistics.
Syntax
reset ip policy-based-route statistics [ policy policy-name ]
Views
User view
Predefined user roles
network-admin
Parameters
policy policy-name: Specifies a policy by its name, a case-sensitive string of 1 to 19 characters. If you do not specify a policy, this command clears PBR statistics for all policies.
Examples
# Clear all PBR statistics.
<Sysname> reset ip policy-based-route statistics