In this post im going to explain policy based routing with "ospf" as a protocol in the below topology,i configured ospf on all the routers to get the full reachability between all the routers, Generally routing decisions by router is based on the routing table but when we configure the policy based routing then the decisions are taken based on the policy based routing configuration.when a packet arrives at particular interface of a router,the incoming packet actually arrives encapsulated inside a data link layer frame then the router strips of the frame and looks into the L3 packet. considering the information in the packet the router thus takes the forwarding decisions by comparing with the routing table.
when the PBR is configured,it intercepts the router's natural destination based forwarding address logic.PBR takes decision by using the matching logic defined through a route map,which in turn refers to the IP ACL.
The router "5.5.5.5" can reach the "12.0.1.0 network" via two routers "4.4.4.4" and "12.12.12.12", take a look at the routing table of "5.5.5.5"
now if we see the R6 path to reach the destination of "12.0.1.1" using traceroute.
the path is via "5.5.5.5" to "12.12.12.12" and to the "12.0.1.1" , now think that we want the traffic to be routed via 4.4.4.4 instead via 12.12.12.12 then configure the policy on 5.5.5.5 router , first create the "route-map" with "ACL" and apply that route-map on the interface.The packets from R6 reach to s0/1 of 5.5.5.5 ,apply the policy on this incoming interface.
interface Serial0/1
ip address 11.2.0.6 255.255.255.252
ip policy route-map ROUTE
now create the route-map with name as "ROUTE" with permit clause and set the next hop as follows
access-list 110 permit ip host 11.2.0.5 12.0.1.0 0.0.0.3
the above configuration exactly matches the frames coming from source 11.2.0.5 to the destination 12.0.1.0/30 network so all the traffic will route through 11.1.0.1
Observe the Result,all the traffic from 11.2.0.5 routed via 11.1.0.1
Result:
when the PBR is configured,it intercepts the router's natural destination based forwarding address logic.PBR takes decision by using the matching logic defined through a route map,which in turn refers to the IP ACL.
The router "5.5.5.5" can reach the "12.0.1.0 network" via two routers "4.4.4.4" and "12.12.12.12", take a look at the routing table of "5.5.5.5"
now if we see the R6 path to reach the destination of "12.0.1.1" using traceroute.
the path is via "5.5.5.5" to "12.12.12.12" and to the "12.0.1.1" , now think that we want the traffic to be routed via 4.4.4.4 instead via 12.12.12.12 then configure the policy on 5.5.5.5 router , first create the "route-map" with "ACL" and apply that route-map on the interface.The packets from R6 reach to s0/1 of 5.5.5.5 ,apply the policy on this incoming interface.
ip address 11.2.0.6 255.255.255.252
ip policy route-map ROUTE
now create the route-map with name as "ROUTE" with permit clause and set the next hop as follows
route-map ROUTE permit 10
match ip address 110
set ip next-hop 11.1.0.1
match ip address 110
set ip next-hop 11.1.0.1
In the above command 110 refers to the access-list that i created, create the access-list as
the above configuration exactly matches the frames coming from source 11.2.0.5 to the destination 12.0.1.0/30 network so all the traffic will route through 11.1.0.1
Observe the Result,all the traffic from 11.2.0.5 routed via 11.1.0.1
Result: