Friday, October 18, 2013

OSPF LOAD BALANCING

OSPF LOAD BALANCING


Load balancing is a standard functionality of the Cisco IOS® router software, and is available across all router platforms. It is inherent to the forwarding process in the router and is automatically activated if the routing table has multiple paths to a destination. It is based on standard routing protocols, such as Routing Information Protocol (RIP), RIPv2, Enhanced Interior Gateway Routing Protocol (EIGRP), Open Shortest Path First (OSPF), and Interior Gateway Routing Protocol (IGRP), or derived from statically configured routes and packet forwarding mechanisms. It allows a router to use multiple paths to a destination when forwarding packets.

For this short blog I will use the OSPF protocol. In this example a client has two WAN connections with two broadband routers that both use for Internet routing. We will enable and disable a load balancing of packets that are sourcing from the HOST to the WEB SERVER.   Following the diagram:


Now let us look at the configuration scripts of the routers:

R1
hostname R1
!
ip cef
no ip domain lookup
ip domain name lab.local
!
interface Loopback0
 ip address 10.1.1.1 255.255.255.255
 ip ospf network point-to-point
!
interface FastEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 duplex auto
 speed auto
!
router ospf 1
 log-adjacency-changes
 network 0.0.0.0 255.255.255.255 area 0

R2
hostname R2
ip cef
no ip domain lookup
ip domain name lab.local
!
interface Loopback0
 ip address 10.2.1.1 255.255.255.255
 ip ospf network point-to-point
!
interface FastEthernet0/0
 ip address 192.168.1.2 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 172.16.1.3 255.255.255.0
 duplex auto
 speed auto
!
router ospf 1
 log-adjacency-changes
 network 0.0.0.0 255.255.255.255 area 0

R3
hostname R3
!
ip cef
no ip domain lookup
ip domain name lab.local
!
interface Loopback0
 ip address 10.3.1.1 255.255.255.255
 ip ospf network point-to-point
!
interface FastEthernet0/0
 ip address 192.168.1.3 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 172.16.1.2 255.255.255.0
 duplex auto
 speed auto
!
router ospf 1
 log-adjacency-changes
 network 0.0.0.0 255.255.255.255 area 0

R4
hostname R4
!
ip cef
no ip domain lookup
ip domain name lab.local
!
interface Loopback0
 ip address 10.4.1.1 255.255.255.255
 ip ospf network point-to-point
!
interface Loopback1
 ip address 99.99.99.99 255.255.255.0
!
interface FastEthernet0/0
 ip address 172.16.1.1 255.255.255.0
 duplex auto
 speed auto
!
router ospf 1
 log-adjacency-changes
 network 0.0.0.0 255.255.255.255 area 0

Now we should see how the HOST router sees the route for the WEB SERVER. That is the 99.99.99.99/32 sub Network that we are interested in LOAD BALANCING.

R1#sh ip route

Gateway of last resort is not set

     99.0.0.0/32 is subnetted, 1 subnets
O       99.99.99.99 [110/3] via 192.168.1.3, 00:12:49, FastEthernet0/0    << LOAD 
                             [110/3] via 192.168.1.2, 00:12:49, FastEthernet0/0          BALANCED >>
     172.16.0.0/24 is subnetted, 1 subnets
O       172.16.1.0 [110/2] via 192.168.1.3, 00:12:49, FastEthernet0/0
                   [110/2] via 192.168.1.2, 00:12:49, FastEthernet0/0
     10.0.0.0/32 is subnetted, 4 subnets
O       10.2.1.1 [110/2] via 192.168.1.2, 00:12:49, FastEthernet0/0
O       10.3.1.1 [110/2] via 192.168.1.3, 00:12:50, FastEthernet0/0
C       10.1.1.1 is directly connected, Loopback0
O       10.4.1.1 [110/3] via 192.168.1.3, 00:12:50, FastEthernet0/0
                 [110/3] via 192.168.1.2, 00:12:50, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0

After we do a TRACEROUTE to the destination we can see that the packets are passing trough two routers and thus load balancing the traffic:


R1#traceroute 99.99.99.99
Type escape sequence to abort.
Tracing the route to 99.99.99.99
  1 192.168.1.3 52 msec
    192.168.1.2 40 msec
    192.168.1.3 28 msec
  2 172.16.1.1 40 msec *  76 msec

OSPF has a built in Protocol Mechanism that uses parameters to calculate the same link between the host and the EDGE routers. We can disable these two "paths" using the maximum-paths command.

R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router ospf 1
R1(config-router)#maximum-paths 1
R1(config-router)#end

Now let us look at the routing table of Router 1:

R1#sh ip route
Gateway of last resort is not set
     99.0.0.0/32 is subnetted, 1 subnets
O       99.99.99.99 [110/3] via 192.168.1.2, 00:00:37, FastEthernet0/0  <<<ONE PATH>>>
     172.16.0.0/24 is subnetted, 1 subnets
O       172.16.1.0 [110/2] via 192.168.1.2, 00:00:37, FastEthernet0/0
     10.0.0.0/32 is subnetted, 4 subnets
O       10.2.1.1 [110/2] via 192.168.1.2, 00:00:37, FastEthernet0/0
O       10.3.1.1 [110/2] via 192.168.1.3, 00:00:37, FastEthernet0/0
C       10.1.1.1 is directly connected, Loopback0
O       10.4.1.1 [110/3] via 192.168.1.2, 00:00:37, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/0

And finally we can do a TRACEROUTE to see the packet flow to the destination of the web server:

R1#traceroute 99.99.99.99
Type escape sequence to abort.
Tracing the route to 99.99.99.99

  1 192.168.1.2 28 msec 52 msec 20 msec  <<FIRST HOPE, ONLY ONE ROUTER>>
  2 172.16.1.1 40 msec *  76 msec
R1#

OSPF can be also tuned under the interface level configuration. This can be done using the command syntax: ip load-sharing per packet. Important thing to remember is not to disable CEF on the routers, in that case you can use up all of the CPU resources. This is done , when routers needs to calculate all over again in the routing table for every load balanced network.

Feel free to comment.

No comments:

Post a Comment