Wednesday, 5 April 2017

PBR configuration Example.

Below is the configuration example of policy based routing.

Routing is done only based on destination but PBR is the method by which routing can be done based on the source as well.

In below example we want that Traffic from PC1 to PC2 must go via R2 and Traffic between PC3 and PC4 will go via Direct connectivity between R1 and R3.

Without PBR R1 will always choose direct link to R3 based on the lowest metric. We manipulated it by configuring PBR to send traffic coming from PC1 and destined to PC2 via R2. 

All other trafic will chose the shortest method.








PC1:-

PC1> show ip

NAME        : PC1[1]
IP/MASK     : 10.1.1.10/24
GATEWAY     : 10.1.1.1
DNS         :
MAC         : 00:50:79:66:68:00
LPORT       : 10005
RHOST:PORT  : 127.0.0.1:10004
MTU:        : 1500

PC3:-

PC3> show ip

NAME        : PC3[1]
IP/MASK     : 30.1.1.10/24
GATEWAY     : 30.1.1.1
DNS         :
MAC         : 00:50:79:66:68:02
LPORT       : 10011
RHOST:PORT  : 127.0.0.1:10010
MTU:        : 1500

R1:-

interface FastEthernet0/0
Description “Connected to R2”
 ip address 12.12.12.1 255.255.255.0
 no shut

interface FastEthernet1/0
Description “Connected to R3”
 ip address 13.13.13.1 255.255.255.0
 no shut

interface FastEthernet2/0
Description “Connected to PC1”
 ip address 10.1.1.1 255.255.255.0
 ip policy route-map PC1_PC2_route
 no shut

interface FastEthernet3/0
Description “Connected to PC3”
 ip address 30.1.1.1 255.255.255.0
 speed auto
 duplex auto

router eigrp 10
 network 10.1.1.1 0.0.0.0
 network 12.12.12.1 0.0.0.0
 network 13.13.13.1 0.0.0.0
 network 30.1.1.1 0.0.0.0

ip access-list extended PC1_PC2_route
 permit ip host 10.1.1.10 host 20.1.1.10

route-map PC1_PC2_route permit 10
 match ip address PC1_PC2_route
 set ip next-hop 12.12.12.2

R2:-

interface FastEthernet0/0
Description “Connected to R1”
 ip address 12.12.12.2 255.255.255.0
 no shut

interface FastEthernet0/1
Description “Connected to R3”
 ip address 23.23.23.2 255.255.255.0
no shut

router eigrp 10
 network 12.12.12.2 0.0.0.0
network 23.23.23.2 0.0.0.0

R3:-

interface FastEthernet0/1
Description “Connected to R2”
 ip address 23.23.23.3 255.255.255.0
no shut

interface FastEthernet1/0
Description “Connected to R1”
 ip address 13.13.13.3 255.255.255.0
no shut

interface FastEthernet2/0
Description “Connected to PC2”
 ip address 20.1.1.1 255.255.255.0
 ip policy route-map PC1_PC2_route
no shut

interface FastEthernet3/0
Description “Connected to PC4”
 ip address 40.1.1.1 255.255.255.0
no shut

router eigrp 10
 network 13.13.13.3 0.0.0.0
 network 20.1.1.1 0.0.0.0
 network 23.23.23.3 0.0.0.0
 network 40.1.1.1 0.0.0.0

ip access-list extended PC1_PC2_route
 permit ip host 20.1.1.10 host 10.1.1.10

route-map PC1_PC2_route permit 10
 match ip address PC1_PC2_route
 set ip next-hop 23.23.23.2


PC2:-

PC2> show ip

NAME        : PC2[1]
IP/MASK     : 20.1.1.10/24
GATEWAY     : 20.1.1.1
DNS         :
MAC         : 00:50:79:66:68:01
LPORT       : 10007
RHOST:PORT  : 127.0.0.1:10006
MTU:        : 1500

PC4:-

Verification:-

PC1:-

PC1> trace 20.1.1.10
trace to 20.1.1.10, 8 hops max, press Ctrl+C to stop
 1   10.1.1.1   15.600 ms  15.600 ms  15.600 ms
 2   12.12.12.2   46.801 ms  46.800 ms  46.800 ms  --<< Going Via R2
 3   23.23.23.3   62.401 ms  62.400 ms  62.401 ms
 4   *20.1.1.10   93.600 ms (ICMP type:3, code:3, Destination port unreachable)

PC1> trace 40.1.1.10
trace to 40.1.1.10, 8 hops max, press Ctrl+C to stop
 1   10.1.1.1   15.600 ms  15.600 ms  15.600 ms
 2   13.13.13.3   46.801 ms  31.200 ms  46.800 ms --<< Going Via R3
 3   *40.1.1.10   93.601 ms (ICMP type:3, code:3, Destination port unreachable)


PC3:-

PC3> trace 20.1.1.10
trace to 20.1.1.10, 8 hops max, press Ctrl+C to stop
 1   30.1.1.1   15.600 ms  15.600 ms  15.600 ms
 2   13.13.13.3   31.200 ms  31.200 ms  46.801 ms
 3   *20.1.1.10   62.400 ms (ICMP type:3, code:3, Destination port unreachable)

PC3> trace 40.1.1.10
trace to 40.1.1.10, 8 hops max, press Ctrl+C to stop
 1   30.1.1.1   15.600 ms  15.601 ms  15.600 ms
 2   13.13.13.3   46.800 ms  31.200 ms  46.801 ms
 3   *40.1.1.10   46.800 ms (ICMP type:3, code:3, Destination port unreachable)

R1:-

R1#sh ip eigrp neighbors
EIGRP-IPv4 Neighbors for AS(10)
H   Address                 Interface       Hold Uptime   SRTT   RTO  Q  Seq
                                            (sec)         (ms)       Cnt Num
1   13.13.13.3              Fa1/0             14 05:00:31   38   228  0  23
0   12.12.12.2              Fa0/0             11 05:03:24   55   330  0  23

R1#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.1.1.0/24 is directly connected, FastEthernet2/0
L        10.1.1.1/32 is directly connected, FastEthernet2/0
      12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        12.12.12.0/24 is directly connected, FastEthernet0/0
L        12.12.12.1/32 is directly connected, FastEthernet0/0
      13.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        13.13.13.0/24 is directly connected, FastEthernet1/0
L        13.13.13.1/32 is directly connected, FastEthernet1/0
      20.0.0.0/24 is subnetted, 1 subnets
D        20.1.1.0 [90/30720] via 13.13.13.3, 04:24:59, FastEthernet1/0
      23.0.0.0/24 is subnetted, 1 subnets
D        23.23.23.0 [90/30720] via 13.13.13.3, 05:00:47, FastEthernet1/0
                    [90/30720] via 12.12.12.2, 05:00:47, FastEthernet0/0
      30.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        30.1.1.0/24 is directly connected, FastEthernet3/0
L        30.1.1.1/32 is directly connected, FastEthernet3/0
      40.0.0.0/24 is subnetted, 1 subnets
D        40.1.1.0 [90/30720] via 13.13.13.3, 05:00:35, FastEthernet1/0

R2:-
R2# sh ip eigrp neighbors
EIGRP-IPv4 Neighbors for AS(10)
H   Address                 Interface       Hold Uptime   SRTT   RTO  Q  Seq
                                            (sec)         (ms)       Cnt Num
1   23.23.23.3              Fa0/1             11 05:01:39   34   204  0  24
0   12.12.12.1              Fa0/0             13 05:04:26  246  1476  0  22

R2#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      10.0.0.0/24 is subnetted, 1 subnets
D        10.1.1.0 [90/30720] via 12.12.12.1, 05:01:33, FastEthernet0/0
      12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        12.12.12.0/24 is directly connected, FastEthernet0/0
L        12.12.12.2/32 is directly connected, FastEthernet0/0
      13.0.0.0/24 is subnetted, 1 subnets
D        13.13.13.0 [90/30720] via 23.23.23.3, 05:01:35, FastEthernet0/1
                    [90/30720] via 12.12.12.1, 05:01:35, FastEthernet0/0
      20.0.0.0/24 is subnetted, 1 subnets
D        20.1.1.0 [90/30720] via 23.23.23.3, 04:25:45, FastEthernet0/1
      23.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        23.23.23.0/24 is directly connected, FastEthernet0/1
L        23.23.23.2/32 is directly connected, FastEthernet0/1
      30.0.0.0/24 is subnetted, 1 subnets
D        30.1.1.0 [90/30720] via 12.12.12.1, 04:39:35, FastEthernet0/0
      40.0.0.0/24 is subnetted, 1 subnets
D        40.1.1.0 [90/30720] via 23.23.23.3, 05:01:21, FastEthernet0/1

R3:-

R3#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      10.0.0.0/24 is subnetted, 1 subnets
D        10.1.1.0 [90/30720] via 13.13.13.1, 05:07:18, FastEthernet1/0
      12.0.0.0/24 is subnetted, 1 subnets
D        12.12.12.0 [90/30720] via 23.23.23.2, 05:07:18, FastEthernet0/1
                    [90/30720] via 13.13.13.1, 05:07:18, FastEthernet1/0
      13.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        13.13.13.0/24 is directly connected, FastEthernet1/0
L        13.13.13.3/32 is directly connected, FastEthernet1/0
      20.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        20.1.1.0/24 is directly connected, FastEthernet2/0
L        20.1.1.1/32 is directly connected, FastEthernet2/0
      23.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        23.23.23.0/24 is directly connected, FastEthernet0/1
L        23.23.23.3/32 is directly connected, FastEthernet0/1
      30.0.0.0/24 is subnetted, 1 subnets
D        30.1.1.0 [90/30720] via 13.13.13.1, 04:45:20, FastEthernet1/0
      40.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        40.1.1.0/24 is directly connected, FastEthernet3/0
L        40.1.1.1/32 is directly connected, FastEthernet3/0

PC2:-


PC2> trace 10.1.1.10
trace to 10.1.1.10, 8 hops max, press Ctrl+C to stop
 1   20.1.1.1   15.600 ms  15.600 ms  15.600 ms
 2   23.23.23.2   31.200 ms  46.800 ms  46.801 ms
 3   12.12.12.1   46.800 ms  31.200 ms  46.801 ms
 4   *10.1.1.10   62.400 ms (ICMP type:3, code:3, Destination port unreachable)

PC2> trace 30.1.1.10
trace to 30.1.1.10, 8 hops max, press Ctrl+C to stop
 1   20.1.1.1   15.600 ms  15.600 ms  15.600 ms
 2   13.13.13.1   46.801 ms  46.800 ms  46.800 ms
 3   *30.1.1.10   62.401 ms (ICMP type:3, code:3, Destination port unreachable)

PC4:-

PC4> trace 10.1.1.10
trace to 10.1.1.10, 8 hops max, press Ctrl+C to stop
 1   40.1.1.1   15.600 ms  15.600 ms  15.600 ms
 2   13.13.13.1   46.801 ms  46.800 ms  46.800 ms
 3   *10.1.1.10   46.800 ms (ICMP type:3, code:3, Destination port unreachable)

PC4> trace 30.1.1.10
trace to 30.1.1.10, 8 hops max, press Ctrl+C to stop
 1   40.1.1.1   15.600 ms  15.600 ms  15.601 ms
 2   13.13.13.1   46.800 ms  31.200 ms  46.801 ms
 3   *30.1.1.10   46.800 ms (ICMP type:3, code:3, Destination port unreachable)




No comments:

Post a Comment