What is source based routing?

we can achieve source based routing by using PBR, first, we need to configure Policy-based routing feature.
In PBR configuration first, we match source address and then we decide where to send those sourced packets.
we can configure PBR in two ways:-

  1. Interface based policy
  2. Local Policy

These two policies are explained below:

  • Interface based policy

whenever a router receives a packet on an interface, the first router check the policy if configured & source of the packet is same then the router will route packet according to that policy and will never check Routing-Table. if the policy is not configured then the router will check routing-table and route packed according to the routing table.

In this topology, we have Three router R1, R2, R3, and, OSPF is running.
so whenever 10.0.0.1 want to communicate 3.3.3.3 R1 will route that traffic directly to R3 because that is best path & R1 is checking destination in Routing-Table. if you want to manipulate this path via R2 so we can configure interface based Policy on R1.
//first we need to configure ACL to the matching source of the traffic.
R1(config)#access-list 1 permit 10.0.0.1 0.0.0.0

//create a route-map to match ACL
R1(config-route-map)#route-map PBR
R1(config-route-map)#match ip address 1 //here we are matching ACL number
R1(config-route-map)#set ip next-hop 12.0.0.2 //here we are defining next hop for all the traffic with source add 10.0.0.1 towards R2

//now we need to apply this route-map on interface with policy.
R1(config)#int f0/0
R1(config-if)#ip policy route-map PBR
R1(config-if)#exit

now whenever R1 receive the packet from ‘10.0.0.1’ on interface f0/0 then R1 will always route this packet towards R2 & will never check routing table.

PBR
PBR
  • Local Policy

If R1 wants to communicate to 3.3.3.3 then we cannot apply interface based policy.
here we need to configure local policy.
any packet generated by R1 should route towards R2 for any destination.
In this topology whenever R1 try to ping 3.3.3.3 so R1 will forward all the traffic directly to R3. now we can configure Local Policy to route traffic via R2.

//here first we need to match source add (on R1 I will match all source add, because R1 can ping destination by using any source address)
R1(config)#access-list 1 permit any

//create a route-map to match ACL
R1(config-route-map)#route-map PBR
R1(config-route-map)#match ip address 1 //here we are matching ACL number
R1(config-route-map)#set ip next-hop 12.0.0.2 //here we are defining next hop for all the traffic with source add 10.0.0.1 towards R2

//now we need to apply this route-map in local Policy.
R1(config)#ip local policy route-map PBR // here we are applying route-map with local policy

now whenever R1 try to ping 3.3.3.3 with any source address then R1 will always route packets towards R2 & will never check Routing-table for any destination.

Leave a Reply

Your email address will not be published.