Load Balance your traffic script

Posted: October 18, 2009 in archlinux, Debian, Slackware

Use this script as your one risk..

If you have 2 adsl line or 2 gateways use this script to loadbalance the line.

———–cut here————–

#!/bin/bash

#IPs of the def gateways

IP1=192.168.1.1

IP2=192.168.2.1

REDLOCAL=10.1.1.0/24

IPLOCAL=10.1.1.1

# NICs

IF1=eth0

IF2=eth1

ip rule add from $IP1 lookup T1

ip route add $REDLOCAL via $IPLOCAL table T1

ip route add 0/0 via $IP1 table T1

ip route add from $IP2 lookup T2

ip route add $REDLOCAL via $IPLOCAL table T2

ip route add 0/0 via $IP1 table T1

ip route default equalize nexthop via $IP1 dev $IF1 nexthop via $IP2 dev $IF2

————–cut here ———————

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