2 ADSL Load Balancing

Posted: December 20, 2009 in archlinux, Debian, Slackware
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. 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

################################################################################################################################

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s