Pages

Showing posts with label Route Manipulation. Show all posts
Showing posts with label Route Manipulation. Show all posts

Friday, January 14, 2011

Tracking in Policy based routing

Tracking in Policy Based Routing

This is a feature introduced in Cisco IOS Software Release 12.3(4)T. Object tracking is used to track th object we are interested such as reachability, routes in routing table for example. The track will return the value pass/fail. One of the application of object tracking is to manipulate route. It is used with the route-map  feature of the router. Example below is the configuration of manipulating route by object tracking.

In this example, we assume that R1 needs to send a packet to destination 100.100.100.100 which is up beyond R2 and R3. R2 and R3 advertise default route to R1 with the equal ospf cost. 




Here is the routing table of R1

R1#sh ip route
<omitted>
Gateway of last resort is 192.168.2.2 to network 0.0.0.0

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/11] via 192.168.2.2, 02:23:50, FastEthernet0/1
C    192.168.1.0/24 is directly connected, FastEthernet0/0
C    192.168.2.0/24 is directly connected, FastEthernet0/1
O*E2 0.0.0.0/0 [110/1] via 192.168.2.2, 02:23:50, FastEthernet0/1
               [110/1] via 192.168.1.2, 02:24:20, FastEthernet0/0
R1#


We can see from the routing table that when R1 needs to send a traffic to 100.100.100.100. It will load balance through R2 and R3 equally. We tested by doing a trace route to 100.100.100.100.


R1#traceroute 100.100.100.100

Type escape sequence to abort.
Tracing the route to 100.100.100.100

  1 192.168.2.2 76 msec
    192.168.1.2 44 msec
    192.168.2.2 48 msec



We want to apply PBR to manipulate routing decision on R1. We configure track 2 and track 3 on R1. If R1 is able to reach 2.2.2.2. It will use R2 (192.168.1.2) as a next hop. If not, it will use R3 (192.168.2.2) as a next hop instead (in the condition of it can reach 3.3.3.3 also). Below is the configuration.

R1
!
// assign tracking object
track 2 ip route 2.2.2.2 255.255.255.255 reachability
!
track 3 ip route 3.3.3.3 255.255.255.255 reachability
!
route-map pbr-test permit 10
 set ip next-hop verify-availability 192.168.1.2 1 track 2
 set ip next-hop verify-availability 192.168.2.2 2 track 3
!
!
// apply policy map to router itself
ip local policy route-map pbr-test 



Verify Configuration

Show tracking operation on R1
Track 2
  IP route 2.2.2.2 255.255.255.255 reachability
  Reachability is Up (OSPF)
    5 changes, last change 00:00:06
  First-hop interface is FastEthernet0/0
  Tracked by:
    ROUTE-MAP 0
Track 3
  IP route 3.3.3.3 255.255.255.255 reachability
  Reachability is Up (OSPF)
    1 change, last change 02:00:51
  First-hop interface is FastEthernet0/1
  Tracked by:
    ROUTE-MAP 0

Trace route at R1 when 2.2.2.2 is up. R1 use R2 as a next-hop.

R1#traceroute 100.100.100.100

Type escape sequence to abort.
Tracing the route to 100.100.100.100

  1 192.168.1.2 96 msec 76 msec 36 msec
  2 192.168.1.2 !H  !H


When the 2.2.2.2 is down.

Track 2
  IP route 2.2.2.2 255.255.255.255 reachability
  Reachability is Down (no route)
    4 changes, last change 00:09:00
  First-hop interface is unknown
  Tracked by:
    ROUTE-MAP 0
Track 3
  IP route 3.3.3.3 255.255.255.255 reachability
  Reachability is Up (OSPF)
    1 change, last change 01:59:59
  First-hop interface is FastEthernet0/1
  Tracked by:
    ROUTE-MAP 0


Trace route at R1 when 2.2.2.2 is down. R1 use R3 as a next-hep instead.

Tracing the route to 100.100.100.100

  1 192.168.2.2 48 msec 56 msec 48 msec
  2 192.168.2.2 !H  !H  *
R1#


*****DEBUG IP POLIOCY********





Tuesday, January 4, 2011

Policy Based Routing (PBR)

Policy Based Routing (Local Traffic)

Policy based routing is one of the ways to manipulate routing decision of the router. It uses access-list to specify what traffic it considered. The traffic information such as source/destination address, protocol, length can be used to match in access-list. Then, we use route-map to direct the traffic to wherever we preferred. The set command in the route map are as followings.



There are 2 ways of applying PBR: interface sub-command and global command. For the interface sub-command, the policy will be apply to the interface itself. However, for the global command, the policy will be applied to the router traffic.

Below is an example of how th PBR works and also the configuration of the router. Here are the tasks in this scenario.

  • Configure interface address and OSPF routing protocol area 0 to all of the routers.
  • Configure OSPF route from R1 getting to 10.10.10.10 at R4 to prefer path through R3 only - configure ospf cost at f0/0 on R1 to 1000.
  • Create access-list at R4, blocking telnet traffic from R1 coming in through R3 and apply to interface f0/1 of R4 ( telnet traffic need to use other path (via R2) in order to get to R4 
  • apply policy to local router to use path R2 if doing telnet to R4.
  • Verify the telnet connectivity.

Here is the diagram


Configure OSPF route from R1 getting to 10.10.10.10 at R4 to prefer path through R3 only - configure ospf cost at f0/0 on R1 to 1000.

interface FastEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 ip ospf cost 1000

After applying the cost, router will have only 1 route to 10.10.10.10 through R3
R1 routing table is shown below

Gateway of last resort is not set

O    192.168.4.0/24 [110/20] via 192.168.3.2, 00:23:29, FastEthernet0/1
     10.0.0.0/32 is subnetted, 1 subnets
O       10.10.10.10 [110/21] via 192.168.3.2, 00:22:21, FastEthernet0/1
C    192.168.1.0/24 is directly connected, FastEthernet0/0
O    192.168.2.0/24 [110/30] via 192.168.3.2, 00:22:21, FastEthernet0/1
C    192.168.3.0/24 is directly connected, FastEthernet0/1
R1#

Because there is an access list blocking telnet packet on f0/1 at R4. We cannot establish the telnet connection to R4.

R1#
R1#telnet 10.10.10.10
Trying 10.10.10.10 ...
% Destination unreachable; gateway or host down

R1#

Apply policy to local router to use path R2 if doing telnet to R4.

**Configure route map matching telnet and set next hop for telnet traffic to R2 instead of R3**
route-map telnet-10 permit 10
 match ip address telnet-10
 set ip next-hop 192.168.1.2


**create access-list match telnet packet**
ip access-list extended telnet-packet
 permit tcp any any eq telnet
 deny   ip any any

**apply on global command**
ip local policy route-map telnet-10
!

Verify telnet connectivity


R1#telnet 10.10.10.10
Trying 10.10.10.10 ... Open

User Access Verification
Password:
R4>


From the example below, PBR can manipulate traffic from using R1->R3->R4 to R1->R2->R4.