1.6 Configure and verify policy-based routing
ENARSI 300-410 v1.1 · 1.0 Layer 3 Technologies
Policy-based routing (PBR) forwards packets by a policy, not only by destination. A route map on the ingress interface matches traffic (an ACL, packet length) and sets the next hop. Packets that match no permit sequence are routed normally. PBR does not change the routing table: show ip route stays the same, and you verify it with show route-map and traceroute.
What you must know
- Configure PBR with
ip policy route-mapon the ingress interface. - Use
set ip next-hop,set ip default next-hop,set interfaceand know which consults the RIB first. - Protect a PBR next hop with
verify-availabilityand IP SLA tracking. - Policy-route the router's own traffic with
ip local policy route-map.
Steering one subnet to a second ISP
ip access-list extended GUEST
permit ip 10.10.99.0 0.0.0.255 any
!
route-map PBR-GUEST permit 10
match ip address GUEST
set ip next-hop verify-availability 198.51.100.1 1 track 20
!
interface GigabitEthernet0/2.99
ip policy route-map PBR-GUEST
!
ip sla 20
icmp-echo 198.51.100.1 source-interface GigabitEthernet0/1
frequency 10
ip sla schedule 20 life forever start-time now
track 20 ip sla 20 reachabilityStaff traffic (1) uses the routing table. Guest traffic (2) is policy-routed to ISP B as long as track 20 is up; when it goes down, the set is skipped and guests fall back to the routing table.
Which set clause does what
| Set clause | Consulted before the RIB? | Use |
|---|---|---|
set ip next-hop A | Yes: PBR wins if A is directly connected and up | Force a path |
set ip default next-hop A | No: only if the RIB has no route except the default | Fallback path |
set interface Gi0/1 | Yes (point-to-point links only) | Force an exit interface |
set ip next-hop recursive A | Yes, A can be several hops away | Next hop behind the neighbour |
Verifying PBR
R1# show route-map PBR-GUEST
route-map PBR-GUEST, permit, sequence 10
Match clauses:
ip address (access-lists): GUEST
Set clauses:
ip next-hop verify-availability 198.51.100.1 1 track 20 [up]
Policy routing matches: 412 packets, 31604 bytes
R1# show ip policy
Interface Route map
Gi0/2.99 PBR-GUESTshow ip policy: is the route map on the ingress interface?show route-map: are the match counters rising? If not, the ACL does not match (check source and direction).show track: is the next hop's track up?traceroutefrom a guest host: the first hop after R1 shows the path taken.debug ip policy(with care) prints each policy-routed or rejected packet.
Commands
show ip policy | Interfaces with a PBR route map. |
show route-map [name] | Match clauses, set clauses, track state and packet counters. |
show track [n] | The object that protects the next hop. |
debug ip policy | Each packet's PBR decision (use with a condition on busy routers). |
Exam traps
- PBR goes on the interface where traffic enters, never where it leaves.
- Locally generated traffic skips interface PBR; use
ip local policy. set ip default next-hopis only used when the RIB has no specific route.- A
denysequence in a PBR route map means "route normally". show ip routedoes not show PBR decisions.
Check yourself
- Guest traffic still goes to ISP A. The route map is on Gi0/0 toward ISP A. What is wrong?
- PBR must be on the ingress interface, the guest subinterface Gi0/2.99.
- What happens when the tracked next hop is down?
- The set clause is skipped and the packet follows the routing table.
- Difference between
set ip next-hopandset ip default next-hop? - The first overrides the RIB; the second applies only when the RIB has no specific route.
- How do you policy-route the router's own pings?
ip local policy route-map <name>in global configuration.
Labs
Try it live: Policy-based routing: guests to a second ISP, with tracking
More topics in 1.0 Layer 3 Technologies
- 1.1 Troubleshoot administrative distance across every routing source
- 1.2 Troubleshoot route maps in any routing protocol: attributes, tags and filters
- 1.3 Troubleshoot routing loop prevention: filters, tags, split horizon and poisoned routes
- 1.4 Troubleshoot redistribution between routing protocols and other route sources
- 1.8 Describe how Bidirectional Forwarding Detection works
- 1.9 Troubleshoot EIGRP in classic and named mode, globally and in a VRF
- 1.10 Troubleshoot OSPFv2 and OSPFv3
- 1.11 Troubleshoot internal and external BGP, globally and in a VRF