Load Balancing with FreeBSD

marjo

Well-Known Member
Joined
Jan 26, 2007
Messages
229
Reaction score
40
Location
Johannesburg
With allot of searching on the internet I found a solution that I modified and it seems to be working.

What I have is two internet accounts. (Actually 3 using 2 servers)

==========
Two Servers
==========
The first FreeBSD server I use to only allow Local SA traffic through my IS local 30GB account.

Then if that server finds that that IP is not an SA ip then it forwards that request to the other server (500+ Routing table that works)
==========

===========
Second Server
===========
This server has a International IS and Telkom accounts that connect through my PPPoE Netgear router.

It then balances the load between them. 50/50
===========

It would work better for people for people that has a Diginet line and an ADSL line to gain more redundancy OR if you have a 1 megabit ADSL and a 512diginet. Then you can set the split to, lets say, 25/75.

Here is my solution:
ipfw -f flush
tun0_gw=`ifconfig tun0 | grep inet | awk '{print $4;}'`
tun1_gw=`ifconfig tun1 | grep inet | awk '{print $4;}'`
ipfw add 00500 check-state
ipfw add 00600 prob 0.500000 skipto 620 ip from 192.168.4.0/24 to not me keep-state
ipfw add 00610 skipto 630 ip from 192.168.4.0/24 to not me keep-state
ipfw add 00620 fwd $tun0_gw ip from 192.168.4.0/24 to not me
ipfw add 00630 fwd $tun1_gw ip from 192.168.4.0/24 to not me

You can specify any gateway, it is just how I set it up.
 
Top
Sign up to the MyBroadband newsletter
X