When you have two ISPs you may want to make your linux machine balance the load of your internet access, you can use ip route
The package needed for this is iproute, if you are using debian you can install it with
apt-get install iproute
or go to this page and download the source of iproute
Let's use this Load Balance Script which work for Centos, Fedora, Ubuntu, Debian and should work for all distributions.
-----------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 ---------------------
that should do the job, off course make the changes on the variables according to your needs.
No comments:
Post a Comment