Wednesday, May 10, 2017

Policy Based Routing using Route Maps

Policy Based Routing is the most preferred way to do traffic engineering in many cases. This post is about a basic PBR configuration.

Topology I use for this lab is simple..

All network segments are /24 subnets.. IP addresses are specified as following.
Ex:- R2-R4 Link
R2's IP =
R4's IP =
this format will continue for every link..
R5 has a Loopback interface with an IP of which represents a connected subnet.
All the routers are EIGRP enabled & currently R2 routes to network through R2-R5 link.

Let's hit a trace route to from R1 to verify the path..

Let's assume that the traffic flow requirement is like the following..

(1) Primary path for the traffic from R1 to must go through R3
(2) If the primary path fails, the traffic should route through R2-R5 link.
(3) All other traffic should route through R4.

Policy based routing should be configured in R2 because it is the point where the traffic can select different paths. This has 3 steps..

STEP-01: Capture the Traffic

Most preferred way to capture a traffic is to use an ACL
R2(config)#ip access-list extended 101
R2(config-ext-nacl)#permit ip any

This ACL will capture any traffic from any source to subnet..

STEP-02: Create a Route Map

Route Map is the core of the PBR. It's like the "If & Else" statements in programming. Here we have "Match & Set". The route-map for this requirement will be like the following..

Create a Route Map named "PBR" to permit set operations with a sequence number 10. Sequence number is just to identify the order in which the map should be read by the router.
R2(config)#route-map PBR permit 10

Configure the sequence 10 of the Route Map to match the ACL 101 and set the next-hop to & in order..
R2(config-route-map)#match ip address 101
R2(config-route-map)#set ip next-hop

Create the sequence 20 of the Route Map "PBR" to match any other traffic which has not captured by the sequence 10 to route to the next hop. Don't use a match statement here as it should match all the traffic. Because the sequence number is higher than the sequence number of the 1st statement, this will be applied to all the traffic which has filtered by the sequence 10. If we don't use this statement, it will route the traffic which has not filtered by the sequence 10 by using the regular routing table
R2(config)#route-map PBR permit 20
R2(config-route-map)#set ip next-hop

Let's see the full map we have configured..

STEP-03: Apply the Policy

The best place to apply a Policy is the incoming interface. In this case you will apply it in the e0/3 interface using the following command.
R2(config)#int e0/3
R2(config-if)#ip policy route-map PBR

Now let's hit a traceroute from R1 to and see the path..

It goes through R3..

Now let's see what happens when the e0/0 interface of R2 is down. I manually shut the interface and hit a traceroute from R1.

It goes through R2-R5 link..

Now let's see how the other traffic destined to the ip addresses of R5 be routed..

It goes through R4 link..

Now we can see that the policy is working as intended.
But if you see the routing table of R2, you cannot see a difference.. Routing table is overwritten..

This example shows the most common type of policy based routing which is used for the traffic which goes through router R2. This is not working for the traffic which is originated from R2. If you want to apply a policy for the traffic which is originated from R2, you must apply it in the global configuration mode using the following command.
R2(config)#ip local policy route-map PBR

In route maps; if you use use 2 or more parameters in line in a match statement, it will trigger logical 'OR' operator and if you use 2 or more parameters line after line in match statements, it will trigger logical 'AND' operator in programming.

Ex:- 'OR' - Either ACL 101 or ACL 102 must match to trigger the set operator
R(config)#route-map PBR permit 10
R(config)#match ip address 101 102
R(config)#set ip next-hop

Ex:-'AND' - Both ACL 101 & ACL 102 must match to trigger the set operator
R(config)#route-map PBR permit 10
R(config)#match ip address 101
R(config)#match ip address 102
R(config)#set ip next-hop

There are a lot of parameters which can be configured with match & set statements of route maps.
You can see them below.

0 comments to “Policy Based Routing using Route Maps”

Post a Comment