- Table of Contents
-
- 06-Layer 3—IP Routing Configuration Guide
- 00-Preface
- 01-Basic IP routing configuration
- 02-Static routing configuration
- 03-RIP configuration
- 04-OSPF configuration
- 05-IS-IS configuration
- 06-EIGRP configuration
- 07-BGP configuration
- 08-Policy-based routing configuration
- 09-IPv6 static routing configuration
- 10-RIPng configuration
- 11-OSPFv3 configuration
- 12-IPv6 policy-based routing configuration
- 13-Routing policy configuration
- 14-DCN configuration
- Related Documents
-
Title | Size | Download |
---|---|---|
08-Policy-based routing configuration | 228.79 KB |
Restrictions and guidelines: PBR configuration
Setting match criteria for a node
Configuring actions for a node
Specifying a policy for local PBR
Specifying a policy for interface PBR
Specifying a policy for outbound PBR on a VXLAN tunnel interface
Enabling the PBR logging feature
Display and maintenance commands for PBR
Example: Configuring packet type-based local PBR
Configuring PBR
About PBR
Policy-based routing (PBR) uses user-defined policies to route packets. A policy can specify parameters for packets that match specific criteria such as ACLs or that have specific lengths. The parameters include the next hop, output interface, SRv6 TE policy, default next hop, and default SRv6 TE policy.
PBR and routing policies have the following differences:
· PBR applies to data packets. PBR takes the specified actions for matching packets based on user demands. The packets will not be forwarded according to routing table lookup. If PBR-based packet forwarding fails, the packets can still be forwarded according to routing table lookup.
· Routing policies apply to routing information. Routing policies typically implement route filtering and route attribute settings. You can use routing policies to change route attributes (including reachability), in order to change the forwarding paths of network traffic.
Packet forwarding process
When the device receives a packet, the device searches the PBR policy for a matching node to forward that packet.
· If a matching node is found and its match mode is permit, the device performs the following operations:
a. Uses the next hops, output interfaces, or SRv6 TE policies specified on the node to forward the packet, or forward the packet in SRv6 BE mode.
b. Searches the routing table for a route (except the default route) to forward the packet if one of the following conditions exists:
- No next hops, output interfaces, or SRv6 TE policies are specified on the node, or packet forwarding in SRv6 BE mode is not set.
- Forwarding failed based on the next hops, output interfaces, or SRv6 TE policies, or failed in SRv6 BE mode.
c. Uses the default next hops or default SRv6 TE policies specified on the node to forward the packet or forward the packet in default SRv6 BE mode if one of the following conditions exists:
- No matching route was found in the routing table.
- The routing table-based forwarding failed.
d. Uses the default route to forward the packet if one of the following conditions exists:
- No default next hops or default SRv6 TE policies are specified on the node, or packet forwarding in default SRv6 BE mode is not set.
- Forwarding failed based on the default next hops or default SRv6 TE policies, or failed in default SRv6 BE mode.
· The device performs routing table lookup to forward the packet in either of the following conditions:
¡ No matching node is found.
¡ A matching node is found, but its match mode is deny.
PBR types
PBR includes the following types:
· Local PBR—Guides the forwarding of locally generated packets, such as ICMP packets generated by using the ping command.
· Interface PBR—Guides the forwarding of packets received on an interface.
· Outbound PBR on a VXLAN tunnel interface—Guides the forwarding of outgoing packets when equal-cost routes exist.
Policy nodes
A policy includes match criteria and actions to be taken on the matching packets. A policy can have one or multiple nodes as follows:
· Each node is identified by a node number. A smaller node number has a higher priority.
· A node contains if-match and apply clauses. An if-match clause specifies a match criterion, and an apply clause specifies an action.
· A node has a match mode of permit or deny.
A policy compares packets with nodes in priority order.
· If a packet matches the criteria on a node, it is processed by the action on the node.
· If the packet does not match any criteria on the node, it goes to the next node for a match.
· If the packet does not match the criteria on any node, the device performs a routing table lookup.
Relationship between if-match clauses
On a node, you can specify multiple types of if-match clauses but only one if-match clause for each type.
To match a node, a packet must match all types of the if-match clauses for the node but only one if-match clause for each type.
Relationship between apply clauses
You can specify multiple apply clauses for a node, but some of them might not be executed. For more information about relationship between apply clauses, see "Configuring actions for a node."
Relationship between the match mode and clauses on the node
Does a packet match all the if-match clauses on the node? |
Match mode |
|
Permit |
Deny |
|
Yes. |
· If the node contains apply clauses, PBR executes the apply clauses on the node. ¡ If PBR-based forwarding succeeds, PBR does not compare the packet with the next node. ¡ If PBR-based forwarding fails, PBR does not compare the packet with the next node. · If the node does not contain apply clauses, the device performs a routing table lookup for the packet. |
The device performs a routing table lookup for the packet. |
No. |
PBR compares the packet with the next node. |
PBR compares the packet with the next node. |
|
NOTE: A node that has no if-match clauses matches any packet. |
PBR and Track
PBR can work with the Track feature to dynamically adapt the availability status of an apply clause to the link status of a tracked object. The tracked object can be a next hop, output interface, default next hop, or default output interface.
· When the track entry associated with an object changes to Negative, the apply clause is invalid.
· When the track entry changes to Positive or NotReady, the apply clause is valid.
For more information about Track-PBR collaboration, see High Availability Configuration Guide.
Restrictions and guidelines: PBR configuration
If a packet destined for the local device matches a PBR policy, PBR will execute the apply clauses in the policy, including the clause for forwarding. When you configure a PBR policy, be careful to avoid this situation.
If traffic matches both a QoS policy configured globally or on an interface by using the MQC approach and a PBR policy configured on an interface (for example, the same ACL rule), PBR applies. Traffic will not match the QoS policy. For more information about QoS commands, see ACL and QoS Command Reference.
PBR tasks at a glance
To configure PBR, perform the following tasks:
b. Setting match criteria for a node
c. Configuring actions for a node
2. Specifying a policy for PBR
Choose the following tasks as needed:
¡ Specifying a policy for local PBR
¡ Specifying a policy for interface PBR
¡ Specifying a policy for outbound PBR on a VXLAN tunnel interface
3. (Optional.) Enabling the PBR logging feature
Configuring a policy
Creating a node
1. Enter system view.
system-view
2. Create a node for a policy, and enter its view.
policy-based-route policy-name [ deny | permit ] node node-number
Setting match criteria for a node
Restrictions and guidelines
On a transport network device, you can configure PBR on the Layer 3 interface to guide the forwarding of packets based on VXLAN IDs. On a VTEP, you can configure PBR on the tunnel interface to guide the forwarding of packets based on VXLAN IDs.
Procedure
1. Enter system view.
system-view
2. Enter policy node view.
policy-based-route policy-name [ deny | permit ] node node-number
3. Set match criteria.
¡ Set an ACL match criterion.
if-match acl { acl-number | name acl-name }
By default, no ACL match criterion is set.
The ACL match criterion cannot match Layer 2 information.
When using the ACL to match packets, PBR uses the action (permit or deny) and time range settings in the ACL.
¡ Set a local QoS ID match criterion.
if-match qos-local-id local-id-value [ qppb-manipulation ]
By default, no local QoS ID match criterion is set.
If you specify the qppb-manipulation keyword, the command applies only to QPPB in which the device acts as a BGP receiver. The device determines that a received packet matches the policy node if the local QoS ID obtained from its matching route entry is identical to the specified local QoS ID criterion. For more information about QPPB, see ACL and QoS Configuration Guide.
This feature takes effect only when the device is used in a QPPB network.
Configuring actions for a node
About apply clauses
The apply clauses allow you to specify the actions to be taken on matching packets on a node.
The following apply clauses determine the packet forwarding paths in a descending order:
· apply access-vpn vpn-instance
· apply next-hop
· apply output-interface
· apply srv6-policy
· apply srv6-be
· apply default-next-hop
· apply default-srv6-policy
· apply default-srv6-be
PBR supports the types of apply clauses shown in Table 1.
Table 1 Priorities and meanings of apply clauses
Clause |
Meaning |
Priority |
apply precedence |
Sets an IP precedence. |
This clause is always executed. |
apply loadshare { next-hop | default-next-hop } |
Enables load sharing among multiple next hops or default next hops. |
Multiple next hop or default 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 hos is selected. When the selected next hop fails, the next available next hop takes over. · Load sharing mode—Multiple next hops load share traffic in proportion to their weight. By default, all next hops have the same weight and traffic is evenly distributed among them. By default, the primary/backup mode applies. For the load sharing mode to take effect, make sure multiple next hops or default next hops are set in the policy. |
apply access-vpn vpn-instance |
Sets VPN instances. |
If a packet matches a forwarding entry of a specified VPN instance, it is forwarded in the VPN instance. |
apply next-hop, apply output-interface, apply srv6-policy, and apply srv6-be |
Sets next hops, output interfaces, and SRv6 TE policies, and the SRv6 BE packet forwarding mode. |
Only the apply clause with the highest priority is executed. |
apply default-next-hop, apply default-srv6-policy, and apply default-srv6-be |
Sets default next hops, default SRv6 TE policies, and the default SRv6 BE packet forwarding mode. |
Only the apply clause with the highest priority is executed. The clauses take effect only in the following cases: · No next hops, SRv6 TE polices, or the default SRv6 BE mode are set or the next hops and SRv6 TE polices are invalid. In addition, the packet fails to be forwarded in default SRv6 BE mode. · The packet does not match any route in the routing table. |
Restrictions and guidelines
For outbound PBR, you can specify only one next hop and the next hop must be directly connected.
If you specify a next hop or default next hop, PBR periodically performs a lookup in the FIB table to determine its availability. Temporary service interruption might occur if PBR does not update the route immediately after its availability status changes.
Configuring actions to modify packet fields
1. Enter system view.
system-view
2. Enter policy node view.
policy-based-route policy-name [ deny | permit ] node node-number
3. Configure actions.
¡ Set an IP precedence.
apply precedence { type | value }
By default, no IP precedence is specified.
Configuring actions to direct packet forwarding
1. Enter system view.
system-view
2. Enter policy node view.
policy-based-route policy-name [ deny | permit ] node node-number
3. Configure actions.
¡ Set VPN instances.
apply access-vpn vpn-instance vpn-instance-name
By default, no VPN instance is specified.
¡ Set next hops.
apply next-hop [ vpn-instance vpn-instance-name ] { ip-address [ direct ] [ track track-entry-number ] }&<1-16>
By default, no next hops are specified.
You can specify a maximum of 16 next hops for backup or load sharing in one command line or by executing this command multiple times.
If multiple next hops on the same subnet are specified for backup, the device first uses the subnet route for the next hops to forward packets when the primary next hop fails. If the subnet route is not available, the device selects a backup next hop.
¡ Enable load sharing among multiple next hops.
apply loadshare next-hop
By default, the next hops operate in primary/backup mode.
¡ Set output interfaces.
apply output-interface { interface-type interface-number [ track track-entry-number ] }
By default, no output interfaces are specified.
This command must be used together with the apply next-hop command. If you only configure this command, the configuration does not take effect.
You can specify a maximum of one output interface for backup or load sharing in one command line or by executing this command multiple times.
¡ Set SRv6 TE policies.
apply srv6-policy { endpoint color [ { sid | vpnsid } sid [ compress-16 block block-length flavor { coc-next | next [ wlib ] } ] ] }&<1-2>
By default, no SRv6 TE policies are specified.
You can specify a maximum of n SRv6 TE policies in one command line or by executing this command multiple times. The first available SRv6 TE policy selected according to configuration order will be used to forward matching packets.
¡ Configure packet forwarding in SRv6 BE mode.
apply srv6-be remote-sid { remote-sid locator-prefix-len }&<1-2>
By default, packets are not forwarded in SRv6 BE mode.
¡ Set default next hops.
apply default-next-hop [ vpn-instance vpn-instance-name ] { ip-address [ direct ] [ track track-entry-number ] }&<1-16>
By default, no default next hops are specified.
You can specify a maximum of 16 default next hops for backup or load sharing in one command line or by executing this command multiple times.
¡ Enable load sharing among multiple default next hops.
apply loadshare default-next-hop
By default, the default next hops operate in primary/backup mode.
¡ Set default SRv6 TE policies.
apply default-srv6-policy { endpoint color [ { sid | vpnsid } sid [ compress-16 block block-length flavor { coc-next | next [ wlib ] } ] ] }&<1-2>
By default, no default SRv6 TE policies are specified.
You can specify a maximum of two default SRv6 TE policies in one command line or by executing this command multiple times. The first available default SRv6 TE policy selected according to configuration order will be used to forward matching packets.
¡ Configure packet forwarding in default SRv6 BE mode.
apply default-srv6-be remote-sid { remote-sid locator-prefix-len }&<1-2>
By default, packets are not forwarded in default SRv6 BE mode.
Specifying a policy for PBR
Specifying a policy for local PBR
About this task
Perform this task to specify a policy for local PBR to guide the forwarding of locally generated packets.
Restrictions and guidelines
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.
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.
Procedure
1. Enter system view.
system-view
2. Specify a policy for local PBR.
ip local policy-based-route policy-name
By default, local PBR is not enabled.
Specifying a policy for interface PBR
About this task
Perform this task to apply a policy to an interface to guide the forwarding of packets received on the interface.
Restrictions and guidelines
You can apply only one policy to an interface and must make sure the specified policy already exists. Before you can apply a new interface PBR policy to an interface, you must first remove the current policy from the interface.
You can apply a policy to multiple interfaces.
When you use interface PBR in conjunction with VXLAN-mode PBR to guide packets on a site-facing interface to a VXLAN tunnel, enable VXLAN-mode PBR before you apply the PBR policy. For more information about VXLAN-mode PBR, see "_Ref522118804."
Procedure
1. Enter system view.
system-view
2. Enter interface view.
interface interface-type interface-number
3. Specify a policy for interface PBR.
ip policy-based-route policy-name [ share-mode ]
By default, no interface policy is applied to an interface.
Specifying a policy for outbound PBR on a VXLAN tunnel interface
About this task
In a VXLAN network, equal-cost routes might exist between two endpoints of a VXLAN tunnel. The device cannot route VXLAN packets to the exact next hop. To choose the desired next hop for outgoing VXLAN packets, use outbound PBR on the VXLAN tunnel interface.
Restrictions and guidelines
You can specify only one policy to a VXLAN tunnel interface and must make sure the specified policy already exists. Before you can apply a new policy to an interface, you must first remove the current policy from the interface.
Procedure
1. Enter system view.
system-view
2. Create a VXLAN tunnel interface and enter tunnel interface view.
interface tunnel tunnel-number mode vxlan
The endpoints of a tunnel must use the same tunnel mode to correctly transmit packets.
3. Specify a policy for outbound PBR.
ip policy-based-route policy-name egress
By default, no policy is specified for outbound PBR on a VXLAN tunnel interface.
Enabling the PBR logging feature
About this task
The PBR logging feature helps the administrator locate and fix faults. The feature logs PBR events and sends the logs to the information center. The information center processes the logs according to output rules. For more information about the information center, see Network Management and Monitoring Configuration Guide.
Procedure
1. Enter system view.
system-view
2. Enable the PBR logging feature.
ip policy-based-route-log enable
By default, the PBR logging feature is disabled.
Display and maintenance commands for PBR
Execute display commands in any view and reset commands in user view.
Task |
Command |
Display PBR policy information. |
display ip policy-based-route [ policy policy-name ] |
Display PBR configuration. |
display ip policy-based-route setup |
Display local PBR configuration and statistics. |
In standalone mode: display ip policy-based-route local [ slot slot-number ] In IRF mode: display ip policy-based-route local [ chassis chassis-number slot slot-number ] |
Display interface PBR configuration and statistics. |
In standalone mode: display ip policy-based-route interface interface-type interface-number [ slot slot-number ] In IRF mode: display ip policy-based-route interface interface-type interface-number [ chassis chassis-number slot slot-number ] |
Clear PBR statistics. |
reset ip policy-based-route statistics [ policy policy-name ] |
PBR configuration examples
Example: Configuring packet type-based local PBR
Network configuration
As shown in Figure 1, Router B and Router C do not have a route to reach each other.
Configure PBR on Router A to forward all TCP packets to the next hop 1.1.2.2 (Router B).
Procedure
1. Configure Router A:
# Configure the IP addresses of Ten-GigabitEthernet 0/0/15 and Ten-GigabitEthernet 0/0/16.
<RouterA> system-view
[RouterA] interface ten-gigabitethernet 0/0/15
[RouterA-Ten-GigabitEthernet0/0/15] ip address 1.1.2.1 24
[RouterA-Ten-GigabitEthernet0/0/15] quit
[RouterA] interface ten-gigabitethernet 0/0/16
[RouterA-Ten-GigabitEthernet0/0/16] ip address 1.1.3.1 24
[RouterA-Ten-GigabitEthernet0/0/16] quit
# Configure ACL 3101 to match TCP packets.
[RouterA] acl advanced 3101
[RouterA-acl-ipv4-adv-3101] rule permit tcp
[RouterA-acl-ipv4-adv-3101] quit
# Configure Node 5 for the policy aaa to forward TCP packets to next hop 1.1.2.2.
[RouterA] policy-based-route aaa permit node 5
[RouterA-pbr-aaa-5] if-match acl 3101
[RouterA-pbr-aaa-5] apply next-hop 1.1.2.2
[RouterA-pbr-aaa-5] quit
# Configure local PBR by applying the policy aaa to Router A.
[RouterA] ip local policy-based-route aaa
2. On Router B, configure the IP address of Ten-GigabitEthernet 0/0/15.
<RouterB> system-view
[RouterB] interface ten-gigabitethernet 0/0/15
[RouterB-Ten-GigabitEthernet0/0/15] ip address 1.1.2.2 24
3. On Router C, configure the IP address of Ten-GigabitEthernet 0/0/16.
<RouterC> system-view
[RouterC] interface ten-gigabitethernet 0/0/16
[RouterC-Ten-GigabitEthernet0/0/16] ip address 1.1.3.2 24
Verifying the configuration
1. Perform telnet operations to verify that local PBR on Router A operates as configured to forward the matching TCP packets to the next hop 1.1.2.2 (Router B), as follows:
# Verify that you can telnet to Router B from Router A successfully. (Details not shown.)
# Verify that you cannot telnet to Router C from Router A. (Details not shown.)
2. Verify that Router A forwards packets other than TCP packets through Ten-GigabitEthernet 0/0/16. For example, verify that you can ping Router C from Router A. (Details not shown.)
Example: Configuring packet type-based interface PBR
Network configuration
As shown in Figure 2, Router B and Router C do not have a route to reach each other.
Configure PBR on Router A to forward all TCP packets received on Ten-GigabitEthernet 0/0/15 to the next hop 1.1.2.2 (Router B).
Procedure
1. Configure IP addresses and unicast routing protocol settings to make sure Router B and Router C can reach Host A. (Details not shown.)
2. Configure Router A:
# Configure ACL 3101 to match TCP packets.
<RouterA> system-view
[RouterA] acl advanced 3101
[RouterA-acl-ipv4-adv-3101] rule permit tcp
[RouterA-acl-ipv4-adv-3101] quit
# Configure Node 5 for the policy aaa to forward TCP packets to next hop 1.1.2.2.
[RouterA] policy-based-route aaa permit node 5
[RouterA-pbr-aaa-5] if-match acl 3101
[RouterA-pbr-aaa-5] apply next-hop 1.1.2.2
[RouterA-pbr-aaa-5] quit
# Configure interface PBR by applying the policy aaa to Ten-GigabitEthernet 0/0/15.
[RouterA] interface ten-gigabitethernet 0/0/15
[RouterA-Ten-GigabitEthernet0/0/15] ip policy-based-route aaa
[RouterA-Ten-GigabitEthernet0/0/15] quit
Verifying the configuration
1. Perform telnet operations to verify that interface PBR on Router A operates as configured to forward the matching TCP packets to the next hop 1.1.2.2 (Router B), as follows:
# Verify that you can telnet to Router B from Host A successfully. (Details not shown.)
# Verify that you cannot telnet to Router C from Host A. (Details not shown.)
2. Verify that Router A forwards packets other than TCP packets through Ten-GigabitEthernet 0/0/17. For example, verify that you can ping Router C from Host A. (Details not shown.)
Example: Configuring source-IP-based interface PBR
Network configuration
As shown in Figure 3, Router B and Router C do not have a route to reach each other.
Configure interface PBR to guide the forwarding of packets received on Ten-GigabitEthernet 0/0/15 of Router A as follows:
· Set the next hop of packets sourced from 192.168.10.2 to 4.1.1.2/24.
· Set the next hop of other packets to 5.1.1.2/24.
Procedure
1. Configure IP addresses and unicast routing protocol settings to make sure Router B can reach Host A and Host B, and Router C can reach Host A and Host B. (Details not shown.)
2. Configure Router A:
# Configure ACL 2000 to match packets sourced from 192.168.10.2.
<RouterA> system-view
[RouterA] acl basic 2000
[RouterA-acl-ipv4-basic-2000] rule 10 permit source 192.168.10.2 0
[RouterA-acl-ipv4-basic-2000] quit
# Configure Node 0 for the policy aaa to forward packets sourced from 192.168.10.2 to next hop 4.1.1.2. Configure Node 1 for the policy aaa to forward other packets to next hop 5.1.1.2.
[RouterA] policy-based-route aaa permit node 0
[RouterA-pbr-aaa-0] if-match acl 2000
[RouterA-pbr-aaa-0] apply next-hop 4.1.1.2
[RouterA-pbr-aaa-0] quit
[RouterA] policy-based-route aaa permit node 1
[RouterA-pbr-aaa-1] apply next-hop 5.1.1.2
[RouterA-pbr-aaa-1] quit
# Configure interface PBR by applying the policy aaa to Ten-GigabitEthernet 0/0/15.
[RouterA] interface ten-gigabitethernet 0/0/15
[RouterA-Ten-GigabitEthernet0/0/15] ip policy-based-route aaa
[RouterA-Ten-GigabitEthernet0/0/15] quit
Verifying the configuration
1. Verify that interface PBR on Router A operates as configured to forward packets sourced from 192.168.10.2 to the next hop 4.1.1.2 and packets sourced from 192.168.10.3 to the next hop 5.1.1.2:
# Configure IP address 192.168.10.3/24 for Host B, and specify its gateway address as 192.168.10.1. (Details not shown.)
# Verify that you can ping Router B from Host A. (Details not shown.)
# Verify that you can ping Router C from Host B. (Details not shown.)
# Verify that you cannot ping Router B from Host B. (Details not shown.)
# Verify that you cannot ping Router C from Host A. (Details not shown.)