Home / Notes / Policy-Based Routing Configuration
NOTES · PBR / TRAFFIC STEERING

Policy-Based Routing: Steering Traffic by Source, Application or Link

Two different problems, the same tool — sending traffic to a specific next hop based on where it came from or what application it is, instead of whatever the routing table would otherwise pick — interface-level matching by source and by application, a network-wide redirect, verification commands, and where policy-based routing stops and route-policy begins.

By the AtlasCommTech engineering team — 13 years of carrier & enterprise network deployments · Updated July 2026

Why Policy-Based Routing, and When Plain Routing Isn't Enough

The routing table answers "how do I reach this destination." Policy-based routing answers a different question: given who's asking and what they're asking for, which way should this particular traffic actually go.

A normal routing table makes one decision per destination, and every host sending to that destination gets the same answer. That's fine until it isn't — until one internal source needs a specific path regardless of what the routing table says about the destination, or one application needs its own path for latency or cost reasons while everything else takes the default route. Policy-based routing (PBR) exists for exactly this gap: it matches traffic first — by source address, protocol, port, whatever a traffic classifier can express — and only then decides the next hop, ahead of and independent from the routing table's own decision.

Below are two worked configurations: matching traffic on a single inbound interface by source address and by application (HTTP), each redirected to a different next hop; and a network-wide policy that redirects one source-destination pair's traffic to a specific router regardless of what the normal routing table — built here by OSPF — would otherwise choose. If your scenario is closer to sending each internet uplink's traffic out its own link with automatic failover, that's a related but different problem — see our dual-WAN failover and load-sharing configuration note for that.

Traffic Plan: What Gets Matched, Where It Goes

One router, several interfaces, and two independent matching rules deciding which packets get redirected before the routing table ever sees them.

GE2/0/0 — inbound traffic-policy pbr inbound 10.2.1.1 · HTTP · everything else Router traffic policy pbr classifier → behavior by precedence order 10.5.1.2 — source match precedence 5 (highest) 10.4.1.2 — unmatched default route, preference 40 10.3.1.2 — HTTP match precedence 10

Diagram labels are kept in English for engineering clarity.

Traffic Classifiers and Redirect Targets

MatchRedirect Next HopPrecedence
ACL 3005 — source 10.2.1.1/3210.5.1.25 — evaluated first
ACL 3006 — destination-port www (HTTP)10.3.1.210
Unmatched traffic10.4.1.2Normal routing table — static route preference 40

Step-by-Step Configuration

Five moves: define the match, pair it with a redirect, bind everything into one policy with precedence, apply it to the right interface and direction, and make sure unmatched traffic still has somewhere to go.

  1. Identify what should be steered differently — a source address, an application (destination port), or a specific source-destination pair — and write an ACL that matches exactly that traffic, nothing broader.
  2. Group each ACL into its own traffic classifier, and pair each classifier with a traffic behavior that redirects matched traffic to a specific next hop with redirect ip-nexthop.
  3. Bind every classifier-behavior pair into one traffic policy, giving each rule a precedence — the lower precedence number is evaluated first when more than one rule could match the same packet.
  4. Apply the traffic policy inbound on the interface where the traffic actually enters the router — traffic-policy is a per-interface, per-direction attachment, not a global one.
  5. Make sure a normal route still exists for traffic that matches none of the policy's rules — PBR only redirects what it explicitly matches; everything else still falls through to the routing table.

Interface Policy-Based Routing — By Source Address and by Application

#
 sysname Router
#
acl number 3005
 rule 0 permit ip source 10.2.1.1 0
#
acl number 3006
 rule 0 permit tcp destination-port eq www
#
traffic classifier 10.2.1.1 operator or
 if-match acl 3005
traffic classifier www operator or
 if-match acl 3006
#
traffic behavior 10.2.1.1
 redirect ip-nexthop 10.5.1.2
traffic behavior www
 redirect ip-nexthop 10.3.1.2
#
traffic policy pbr
 classifier 10.2.1.1 behavior 10.2.1.1 precedence 5
 classifier www behavior www precedence 10
#
interface GigabitEthernet2/0/0
 ip address 10.1.2.1 255.255.255.0
 traffic-policy pbr inbound
#
interface GigabitEthernet2/0/1
 ip address 10.3.1.1 255.255.255.0
#
interface GigabitEthernet2/0/2
 ip address 10.4.1.1 255.255.255.0
#
interface GigabitEthernet2/0/3
 ip address 10.5.1.1 255.255.255.0
#
ip route-static 192.168.1.0 24 10.3.1.2
ip route-static 192.168.1.0 24 10.4.1.2 preference 40
ip route-static 192.168.1.0 24 10.5.1.2
#
return

Three static routes reach the same 192.168.1.0/24 prefix on purpose — 10.4.1.2 carries the lower preference (40) so it wins the routing table's own selection for unmatched traffic, while 10.3.1.2 and 10.5.1.2 stay reachable purely so PBR's redirected next hops are valid.

Network-Wide Policy-Based Routing — Redirecting One Source-Destination Flow

A different, larger network illustrates this at scale: RouterA, RouterB and RouterC share routes through OSPF, and the routing table alone would send 10.0.2.0/24-to-10.0.0.0/24 traffic via RouterC. A traffic policy on RouterA redirects that one flow to RouterB instead.

RouterA — the traffic policy and the OSPF underlay

#
acl number 3001
 rule 5 permit ip source 10.0.2.0 0.0.0.255 destination 10.0.0.0 0.0.0.255
#
traffic classifier rdt operator or
 if-match acl 3001
#
traffic behavior rdt
 redirect ip-nexthop 10.181.10.2
#
traffic policy rdt
 classifier rdt behavior rdt
#
interface GigabitEthernet1/0/0
 ip address 10.181.20.1 255.255.255.0
#
interface GigabitEthernet2/0/0
 ip address 10.181.10.1 255.255.255.0
#
interface GigabitEthernet3/0/0
 ip address 10.0.2.1 255.255.255.0
 traffic-policy rdt inbound
#
ospf 1
 area 0.0.0.0
  network 10.0.2.0 0.0.0.255
  network 10.181.20.0 0.0.0.255
  network 10.181.10.0 0.0.0.255
#
return

RouterB — the redirect target

#
interface GigabitEthernet1/0/0
 ip address 10.181.10.2 255.255.255.0
#
interface GigabitEthernet2/0/0
 ip address 10.184.10.1 255.255.255.0
#
ospf 1
 area 0.0.0.0
  network 10.181.10.0 0.0.0.255
  network 10.184.10.0 0.0.0.255
#
return

RouterC — the OSPF-preferred path that gets bypassed for this one flow

#
interface GigabitEthernet1/0/0
 ip address 10.181.20.2 255.255.255.0
#
interface GigabitEthernet2/0/0
 ip address 10.184.10.2 255.255.255.0
#
ospf 1
 area 0.0.0.0
  network 10.184.10.0 0.0.0.255
  network 10.181.20.0 0.0.0.255
  network 10.0.0.0 0.0.0.255
#
return

Policy-Based Routing vs. Route-Policy — Two Different Layers of "Policy"

Despite the similar name, route-policy is a completely different mechanism operating on a different plane. Route-policy (configured with route-policy ... permit/deny node ...) filters and modifies routes themselves as they're learned or advertised between routing protocols — for example applying a local-preference or community attribute to BGP routes, or controlling which routes get redistributed from one protocol into another. Policy-based routing, by contrast, never touches the routing table or the routes in it — it intercepts already-arrived packets on an interface and forwards them to a specific next hop based on a traffic classifier, regardless of what the routing table says. A route-policy changes what routes exist and how they're tagged; a traffic policy with PBR changes where already-decided packets actually go. One detail worth borrowing from route-policy configuration: a route-policy needs an explicit, empty permit node at the end, or routes that matched none of the earlier nodes get silently filtered out — a different failure mode from PBR's own unmatched-traffic behavior, but a similar instinct to check for.

Related solution designs

How to Confirm It's Actually Redirecting

Check the classifier, the behavior and the policy independently, then confirm with a trace that traffic actually leaves through the redirected next hop.

  1. Run display traffic classifier user-defined [classifier-name] — confirm each classifier matches the ACL you expect.
  2. Run display traffic behavior {system-defined | user-defined} [behavior-name] — confirm each behavior's redirect next hop is correct.
  3. Run display traffic policy user-defined [policy-name [classifier classifier-name]] — confirm the precedence ordering inside the bound policy.
  4. Run display traffic-policy applied-record [policy-name] — confirm the policy is actually applied to the interface and direction you intended.
  5. From a matching source, run a trace to the destination and confirm the path actually goes through the redirected next hop, not whatever the routing table alone would have chosen.
<Host> tracert -a 10.0.2.1 10.0.0.1

 1  10.181.20.1     3 ms  2 ms  1 ms
 2  10.181.10.2     4 ms  3 ms  3 ms
 3  10.184.10.1     5 ms  4 ms  4 ms
 4  10.0.0.1        6 ms  5 ms  5 ms

The second hop (10.181.10.2) is RouterB's address — confirming the traffic policy redirected this flow there instead of the OSPF-preferred path through RouterC. Your own hop addresses and timings will differ; what matters is which router the trace passes through.

4 Configuration Gotchas

The ones that turn a working redirect into traffic that silently goes the wrong way, or nowhere at all.

1. A Traffic Policy With No Match Still Needs Somewhere to Fall Through To

SYMPTOMTraffic that clearly doesn't match any classifier in the policy still ends up dropped or misrouted, instead of just following the normal routing table.

CAUSEApplying traffic-policy inbound on an interface doesn't create a default-deny the way some ACL logic does — but if the interface's normal route to that destination is itself missing or wrong, there's nothing sane for unmatched traffic to fall back to. PBR only decides for what it explicitly matches; everything else needs a working routing table entry to begin with.

FIXConfirm normal reachability (a route in display ip routing-table) for the destination before layering PBR on top — PBR replaces the next hop for matched traffic, it doesn't create reachability out of nothing.

2. The Redirect Next Hop Doesn't Have to Win the Routing Table — It Just Has to Be Reachable

SYMPTOMA static route to the redirect next-hop address exists, but display ip routing-table shows a completely different route winning for that same prefix.

CAUSEredirect ip-nexthop forwards matched packets to that address directly — it doesn't require that address's route to be the routing table's own best path. In the worked configuration here, three static routes to the same prefix coexist deliberately: one wins the routing table's own selection (lowest preference value) for unmatched traffic, while the other two exist purely so PBR's redirected next hops are reachable at all.

FIXDon't assume the redirect next hop needs to "win" any route comparison — verify reachability to it directly (ping it, or check the specific static route), not by checking which route the table currently prefers.

3. Precedence Decides Which Classifier Wins When a Packet Could Match More Than One

SYMPTOMA packet that should clearly hit the more specific rule — say, one matching a specific source address — instead gets redirected by the broader application-based rule, or vice versa.

CAUSEA traffic policy evaluates its classifier-behavior pairs in precedence order — lower precedence number first — and stops at the first match, the same way an ACL stops at its first matching rule. If the more general rule has a lower precedence number than the more specific one, the general rule wins even when both could match.

FIXGive the more specific match the lower precedence number, exactly as in the worked configuration — the source-address match sits at precedence 5, ahead of the application match at precedence 10.

4. traffic-policy inbound Only Sees Traffic Entering That Interface, Not Traffic Already Inside the Router

SYMPTOMTraffic that clearly matches the ACL used in a classifier still isn't redirected.

CAUSEThe policy is bound with a direction — inbound on one specific interface. It only evaluates traffic as it arrives on that exact interface in that direction; traffic originating elsewhere on the router, or arriving on a different interface, never passes through that policy at all.

FIXConfirm which physical interface the traffic in question actually enters through, and make sure that's the interface — and direction — the traffic-policy is applied to, not just any interface in the path.

5. PBR and Route-Policy Solve Different Problems Even Though Both Say "Policy"

SYMPTOMSomeone tries to steer one specific source's traffic to a specific next hop by editing a route-policy applied to a routing protocol, and it does nothing for that traffic.

CAUSERoute-policy shapes which routes exist and their attributes in the control plane — it has no concept of "this specific source's packets," only of routes and their attributes as protocols exchange them. Steering one source's traffic to a specific next hop, regardless of the destination's normal best route, is a data-plane, per-packet decision — that's what PBR is for.

FIXUse PBR when the deciding factor is something about the packet itself (source, protocol, port); use route-policy when the deciding factor is something about the route (which protocol learned it, its attributes, whether it should be redistributed at all).

Honest Limits of This Note

Honest Limits of This Note

This note is based on two worked configurations: interface-level PBR matching by source address and by HTTP destination port with two independent redirect targets, and a network-wide PBR redirect layered on top of an OSPF-routed network. It doesn't cover PBR based on packet length or DSCP/precedence marking, load-balancing traffic across more than one redirect next hop, or applying policy-based routing outbound rather than inbound. It also doesn't cover route-policy itself in depth — route-policy shapes routes, not packets, and deserves its own treatment; what's here is only the distinction needed to pick the right tool.

Five Questions Worth Having an Answer For

Pulled from the same configuration cases this note is built on.

Does policy-based routing replace the routing table?

No — it sits ahead of it for matched traffic only. Anything a traffic classifier doesn't explicitly match still falls through to the normal routing table exactly as if PBR weren't configured at all.

Can I match on more than source address and destination port?

Yes — anything an ACL (or a more complex traffic classifier) can express is fair game: source, destination, protocol, port ranges, and more. The two examples here — source address and HTTP destination port — are simply the ones the underlying worked configuration illustrates.

What's the actual difference between this and route-policy?

Route-policy operates on routes themselves — filtering or tagging what a routing protocol learns or advertises. PBR operates on packets that have already arrived — redirecting them to a specific next hop based on a traffic classifier, without changing any route or route attribute at all. See the comparison in the configuration section above for the full distinction.

I want each internet uplink to carry its own traffic with automatic failover — is that the same thing as this note?

It's related but distinct. That's usually built with equal- or unequal-preference static routes (for load sharing or primary/backup) rather than a traffic-policy redirect — see our dual-WAN failover and load-sharing configuration note for that specific design.

Do I need a static route to the redirect next hop even though PBR is deciding the path?

Yes — redirect ip-nexthop still needs that next-hop address to be genuinely reachable; PBR decides that a matched packet goes there, but it doesn't manufacture reachability. As shown in gotcha 2 above, that route doesn't need to be the routing table's own preferred path for the prefix, it just needs to exist.

Can policy-based routing be applied outbound instead of inbound?

The configuration keyword supports both directions, but inbound on the interface where the traffic actually originates from the source you're matching is the far more common and predictable placement — it catches the traffic at the earliest point, before any other forwarding decision has a chance to apply.

Need specific traffic sent down a specific path?

Tell us which traffic — by source, application or link — needs to go where, and we'll help you write the classifier and precedence order correctly.

WhatsApp an engineer →

Related Reading