2 ADSL Load Balancing
I think most of us wants to speed up our DSL link but don't know much about it. Well here is the extracted script (bash) written by mambang from mambang.org. Credit to him for writing up this script. Dual gateway using 3 nic and 4 ips with one alias
I'll pretty much want to say Voila! to the author of this script. I've credit the author properly now so moving along smoothly. To most people out there wants to give it a shot on this scripts, all u need is 2 ADSL line , regardless whether it's a dynamic IP or static IP or even "combo" package (you know what i mean hehe) it can be done.
First of all you will need to install a linux/unix (debian flavour is recommended) with 3 NIC (Network Interface Card) . The first and the second NIC will be used for ADSL connection and the third NIC used for internal LAN routing. So to get it working, you will need to set both of your modem to dial itself in order for the NIC's to recognize the gateway. After that , you will need to create a file and name it
splitgateway in /etc/init.d/ folder.
Put the script in here and chmod by using the command " chmod a+x splitgateway"
and run it. And start surfin to knowledgebank.oscc.org.my - Happy Surfing and stay safe
!/bin/sh
# dual gateway using 3 nic and 4 ips with one alias
# isp1 on eth0
# isp2 on eth1
# eth2 = for LAN group1
# eth2:1= for LAN group2
#
# Created by mambang 2007
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
IFCONFIG=/sbin/ifconfig
NETWORK=/etc/init.d/networking
IP=/sbin/ip
NAME="MULTI-GATEWAY"
DESC1="ROUTING TABLE"
GATEWAY1=192.168.1.1
GATEWAY2=192.168.2.1
NET1=192.168.1.11 #ip eth0
NET2=192.168.2.22 #ip eth1
LAN1=10.0.0.1 #ip LAN1 = eth2
LAN2=176.16.0.1 #ip LAN2 = eth2:2
SUB1=192.168.1.0/24 #sub local
SUB2=192.168.2.0/24 #sub local
SUB3=10.0.0.0/24 #subnet client LAN1
SUB4=176.16.0.0/24 #subnet client LAN2
DEV1=eth0
DEV2=eth1
DEV3=eth2
DEV4=eth2:1
case "$1" in
start)
echo -n "Memulakan $DESC1: "
# Setup source IP routing rules for DSL 1
$IP route add $SUB1 dev $DEV1 src $NET1 table T1
$IP route add default via $GATEWAY1 table T1
$IP route add $SUB2 dev $DEV2 src $NET2 table T2
$IP route add default via $GATEWAY2 table T2
$IP route add $SUB1 dev $DEV1 src $NET1
$IP route add $SUB2 dev $DEV2 src $NET2
$IP route add default via $GATEWAY1
$IP rule add from $NET1 table T1
$IP rule add from $NET2 table T2
$IP route add $SUB3 dev $DEV3 table T1
$IP route add $SUB2 dev $DEV2 table T1
$IP route add 127.0.0.0/8 dev lo table T1
$IP route add $SUB4 dev $DEV4 table T2
$IP route add $SUB1 dev $DEV1 table T2
$IP route add 127.0.0.0/8 dev lo table T2
echo "$NAME1"
;;
stop)
echo "Menghentikan $DESC1 $NAME ... "
$IP route flush all
$IFCONFIG $NET1 down
$IFCONFIG $NET2 down
$IFCONFIG $LAN1 down
$IFCONFIG $LAN2 down
$NETWORK restart
echo "Default routing table restored"
;;
*)
N=/etc/init.d/splitgateway
echo "Cara Guna: $N {start|stop}" >&2
exit 1
;;
esac
exit 0

