About policy-based routing
Policy-based routing is a method that enables the configuration of defined policies for IPv4 and IPv6 traffic flows, allowing for more granular control over packet forwarding decisions beyond standard routing protocols.
-
All packets received on an interface with policy-based routing enabled are processed through enhanced packet filters or route maps.
-
Route maps dictate the policy that determines where to forward packets.
-
Policy-based routing lessens the reliance on routes derived from routing protocols.
Policy-based routing includes the following features:
-
Source-based routing—Routes traffic that originates from different sets of users through different connections across the policy routers.
-
Quality of Service (QoS)—Differentiates traffic by setting the precedence or type of service (ToS) values in the IP packet headers at the periphery of the network and leveraging queuing mechanisms to prioritize traffic in the core or backbone of the network (see the Cisco Nexus 9000 Series NX-OS Quality of Service Configuration Guide).
-
Load sharing—Distributes traffic among multiple paths based on the traffic characteristics.
Policy route maps
A policy route map is a set of entries, each containing match and set statements that determine how packets are routed based on defined criteria.
-
Match statements specify the conditions that packets must meet for a policy to apply.
-
Set clauses define the routing actions to be taken when the match criteria are met.
-
Each route-map statement can be marked as permit or deny, affecting how packets are processed.
How policy route maps process packets
Policy route maps use permit and deny statements to control packet routing based on match criteria.
-
If a statement is marked as permit and the packets meet the match criteria, the set clause is applied, such as choosing the next hop.
-
If a statement is marked as deny , packets that meet the match criteria are sent back through normal forwarding channels and destination-based routing is performed.
-
If a statement is marked as permit and packets do not match any route-map statements, the packets are sent back through normal forwarding channels and destination-based routing is performed.
![]() Note |
Policy routing is specified on the interface that receives the packets, not on the interface from which the packets are sent. |
Set criteria for policy-based routing
The set criteria for policy-based routing define how packets are forwarded by specifying next-hop addresses, VRFs, or interfaces in route maps.
-
Commands are mutually exclusive within a route-map sequence.
-
The first command uses the IP address of the adjacent next-hop router to forward packets.
-
If no match criteria are met, packets are routed through the normal destination-based process.
The following set commands are supported for route maps in policy-based routing:
-
set { ip | ipv6 } next-hop
-
set interface null0
In the first command, the IP address specifies the adjacent next-hop router in the path toward the destination to which the packets should be forwarded. The first IP address associated with a currently up connected interface is used to route the packets.
![]() Note |
You can optionally configure this command for next-hop addresses to load balance traffic for up to 32 IP addresses. In this case, Cisco NX-OS sends all traffic for each IP flow to a particular IP next-hop address. |
If the packets do not meet any of the defined match criteria, those packets are routed through the normal destination-based routing process.
Route-map processing logic
Route-map processing logic defines how packets are evaluated and routed based on the sequence and type of route-map statements (permit or deny), the presence of match and set commands, and the status of next-hop addresses.
-
Each route-map statement is processed in sequence when a packet is received on an interface with a route map.
-
If a statement is permit , the packet is matched against the match command criteria, and if matched, the set command action is executed.
-
If a statement is deny , the packet is matched against the match command criteria, and if matched, policy-based routing stops and the default routing table is used.
Route-map statement processing and next-hop handling
When an interface with a route map receives a packet, the forwarding logic processes each route-map statement according to the sequence number.
-
If the route-map configuration does not contain a match statement, the policy-based routing logic executes the action specified by the set command on the packet. All packets are routed using policy-based routing.
-
If the route-map configuration references a match statement but the match statement references a non-existing ACL or an existing ACL without any access control entries (ACEs), the packet is routed using the default routing table.
-
If the next-hop specified in the set { ip | ipv6 } next-hop command is down, is not reachable, or is removed, the packet is routed using the default routing table.
-
If the route-map statement encountered is a route-map... permit statement, the packet is matched against the criteria in the match command. If the packet matches the permit ACEs in the ACL, the policy-based routing logic executes the action that the set command specifies on the packet.
-
If the route-map statement encountered is a route-map... deny statement, the packet is matched against the criteria in the match command. If the packet matches the permit ACEs in the ACL, policy-based routing processing stops, and the packet is routed using the default IP routing table.
![]() Note |
The set command has no effect inside a route-map... deny statement. |
Beginning Cisco NX-OS Release 9.2(3), you can balance policy-based routing traffic if the next hop is recursive over ECMP paths using the next-hop ip-address load-share command. This situation is supported on the following switches, line cards, and modules:
-
N9K-C9372TX
-
N9K-X9564TX
-
N9K-X9732C-EX
For all the next hop routing requests, the Routing Profile Manager (RPM) resolves them using unicast Routing Information Base (uRIB). RPM also programs all ECMP paths, which helps to uniformly load balance all the ECMP paths. PBR over ECMP is supported only on IPv4.

Feedback