LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-27-2005, 01:22 AM   #1
tkt
Member
 
Registered: Apr 2005
Posts: 37

Rep: Reputation: 15
How to do load balancing


Hi,

I read through some thread regarding load balancing in the forum, but couldn't find solution there. I read through another article on load balancing which perform split access before load balancing using two NICs with two DSL lines. It says that rt_tables needs to be editted, but I don't really get the meaning. I'll paste the ip rules here and elaborate based on my understanding. Hope that someone could correct me if I'm wrong.

"Let us first set some symbolical names. Let $IF1 be the name of the first interface (if1 in the picture above) and $IF2 the name of the second interface. Then let $IP1 be the IP address associated with $IF1 and $IP2 the IP address associated with $IF2. Next, let $P1 be the IP address of the gateway at Provider 1, and $P2 the IP address of the gateway at provider 2. Finally, let $P1_NET be the IP network $P1 is in, and $P2_NET the IP network $P2 is in.

One creates two additional routing tables, say T1 and T2. These are added in /etc/iproute2/rt_tables. Then you set up routing in these tables as follows:

ip route add $P1_NET dev $IF1 src $IP1 table T1
ip route add default via $P1 table T1
ip route add $P2_NET dev $IF2 src $IP2 table T2
ip route add default via $P2 table T2

Next you set up the main routing table. It is a good idea to route things to the direct neighbour through the interface connected to that neighbour. Note the `src' arguments, they make sure the right outgoing IP address is chosen.

ip route add $P1_NET dev $IF1 src $IP1
ip route add $P2_NET dev $IF2 src $IP2


Then, your preference for default route:

ip route add default via $P1
Next, you set up the routing rules. These actually choose what routing table to route with. You want to make sure that you route out a given interface if you already have the corresponding source address:

ip rule add from $IP1 table T1
ip rule add from $IP2 table T2
p route add $P0_NET dev $IF0 table T1
ip route add $P2_NET dev $IF2 table T1
ip route add 127.0.0.0/8 dev lo table T1
ip route add $P0_NET dev $IF0 table T2
ip route add $P1_NET dev $IF1 table T2
ip route add 127.0.0.0/8 dev lo table T2

ip route add default scope global nexthop via $P1 dev $IF1 weight 1 \
nexthop via $P2 dev $IF2 weight 1"

My understanding is that, firstly, routing table, T1 and T2 are created in rt_tables with subnet PI_net routed to NIC IF1 with IP of IP1, and subnet P2_net routed to NIC2 IF2 with IP of IP2. Default gateway for NIC IF1 is P1 and NIC IF 2 of P2.

"ip rule add from $IP1 table T1" means rule in routing table T1 would use NIC1 with IP of IP1
and for the part of "ip route add $Po_net ..." onwards, it means subnet 0 and 2 would use routing table T1 and subnet 0 and 1 would use routing table T2 and for subnet 127.0.0.0/8, it is not routed.

For "ip route add default scope global nexthop via $P1 dev $IF1 weight 1 \
nexthop via $P2 dev $IF2 weight 1", I don't understand at all. Can someone explain to me?

Thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Load Balancing otisthegbs Linux - Networking 4 02-10-2005 02:16 PM
how to do load balancing? yenonn Linux - Networking 2 07-27-2004 09:20 PM
load balancing on rh ntaizi Linux - Software 0 12-17-2003 06:41 AM
new to load balancing suliu Linux - General 3 05-12-2003 08:08 AM
Load balancing ?? Lucsi Linux - Newbie 1 07-16-2002 12:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration