You are not logged in.

#1 2009-09-07 02:41:48

dextro_
Member
Registered: 2009-09-07
Posts: 24

WAN round-robin load balancing

First things first, I just recently got that horrible distribution Gentoo off my machine and installed Arch for a test run and so far a flipping love it. Just like to thank everyone that made this wonderful piece of Linux.

To the point: I have a box with 3 NIC and it current runs as my LAN gateway. http://pastie.org/608016 is the script I use to do so and as you may have guessed eth0 is my DSL modem eth1 is my LAN switch, eth2 is my cable modem. Currently my LAN runs off just my DSL, if I want to change this and run off the cable I have to change WAN in the script to eth2 and run it. I would like to change this and have it round-robin load balance over my DSL, cable.

I tried

ifconfig eth0 down
ifconfig eth2 down
modprobe bonding mode=0 miimon=100
ifconfig bond0 10.0.0.5
ifenslave bond0 eth0
ifenslave bond0 eth2

inspired by http://ubuntulinuxhelp.com/how-to-use-t … -computer/ and that didn't work at all.

Then I had a look at http://wiki.archlinux.org/index.php/Con … rk#bonding (two ip on two card) but that didn't really make sense to be as you're not specifying what interfaces to bond anywhere.

Could anyone help me?

Offline

#2 2009-09-07 03:41:31

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: WAN round-robin load balancing

Bonding won't help because you're connecting to 2 completely different networks via 2 completely different paths.

You can't do true round-robin with this setup, because if you establish a TCP session for example on a download, and part of the traffic comes from IP address A (DSL) and part of the traffic comes from IP address B (cable) then the remote server is just going to absolutely bork.

You can round-robin the *connections*, but not individual packets. There is a method in the iproute2 software that does this, but I've never investigated it. Normally I set these kind of situations up to push the non-time critical services out one (slower) link such as FTP, email etc and the time-critical services such as WWW, SSH etc via the other (faster) link.

Offline

#3 2009-09-07 04:32:20

dextro_
Member
Registered: 2009-09-07
Posts: 24

Re: WAN round-robin load balancing

http://lartc.org/howto/lartc.rpdb.multiple-links.html is that the iproute2 method you speak of? I just want to randomly spread the connections over the links.

Offline

#4 2009-09-07 05:33:18

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: WAN round-robin load balancing

Yep, that's exactly the setup I meant smile

Offline

#5 2009-09-07 05:43:41

dextro_
Member
Registered: 2009-09-07
Posts: 24

Re: WAN round-robin load balancing

Okay, I have this feeling that if I go ahead and do http://lartc.org/howto/lartc.rpdb.multiple-links.html my LAN script is still only going to use eth0 (as its specified to) http://pastie.org/608016 if so, what do I need to change so it uses the random routes for each connecton?

Offline

#6 2009-09-07 06:35:15

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: WAN round-robin load balancing

Instead of choosing one of the two providers as your default route, you now set up the default route to be a multipath route. In the default kernel this will balance routes over the two providers. It is done as follows (once more building on the example in the section on split-access):

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

This will balance the routes over both providers. The weight parameters can be tweaked to favor one provider over the other.

Last edited by fukawi2 (2009-09-07 06:35:30)

Offline

#7 2009-09-13 01:42:23

dextro_
Member
Registered: 2009-09-07
Posts: 24

Re: WAN round-robin load balancing

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

What does it mean by 'IP network' ($P*_NET)?

Offline

#8 2009-09-13 04:28:12

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: WAN round-robin load balancing

dextro_ wrote:

What does it mean by 'IP network' ($P*_NET)?

The network and subnet mask of the directly connected interface for each network connection. If you have the public IP address assigned to the actual box, then it will probably be a /30 network, eg:

75.127.96.189/30

or if there's private address space between your box and the router (ADSL or Cable modem) then probably a /24 network, eg:

192.168.1.0/24

The output of `ip a s` will tell you the addresses and subnet masks on all your interfaces, then you can use the 'ipcalc' tool to convert that to a CIDR format mask like /24 or /30 etc

Offline

Board footer

Powered by FluxBB