Your Ad Here
 
Questions ? info@easylivecd.com

EasyLiveCD.com
LiveCD Software Solutions
Linux LiveCD Router new
free Download
Hotspot Server
Media Server
Documentation
Site Search
Questions ?
info@easylivecd.com
Hardware
Webcams
Firewall
VoIP
News
VoIP
Linux Router
Firewall
Hotspot
Twitter
Tutorials new


Languages
es it fr pt de gr fi cn ko ja ru hi ar lang world
Write to us info@easylivecd.com

Indice de la Documentación

Load Balancing with multiple ISP

1.

Define the local subnets on local interface with following commands

#ifconfig eth0 192.168.0.1 netmask 255.255.255.0

#ifconfig eth0:0 172.16.0.1 netmask 255.255.255.0

#ifconfig eth0:1 172.16.1.1 netmask 255.255.255.0

2.

Assume that your two wan interfaces are eth1 and eth2 respectively.
3.

Give ips to eth1 and eth2.
4.

#ifconfig eth1 210.211.251.189 netmask 255.255.255.224

#ifconfig eth2 192.168.1.253 netmask 255.255.255.224

5.

If you want to load balance the traffic with 1:1 ratio , give command,

#ip route add default equalize nexthop via 210.211.251.1 dev eth1 nexthop via 192.168.1.1 dev eth2

6.

Add two routing tables to your load balance server.

#echo table1 > /etc/iproute2/rt_tables

#echo table2 > /etc/iproute2/rt_tables

Table1 wil be used for defining default route for ISP1 and table2 will be used for defining default route or ISP2.

7.Next step is to make rules to tell your load balance server which subnet will go which way,

#ip rule add from 210.211.251.189 lookup table1

#ip rule add from 192.168.1.253 loookp table2

#ip rule add from 172.16.0.0/24 lookup table1

#ip rule add from 172.16.1.0/24 lookup table2

8. Add routes for local subnets.

#ip route add 192.168.0.1/24 via 192.168.0.1 table1

#ip route add 192.168.0.1/24 via 192.168.0.1 table2

#ip route add 172.16.0.1/24 via 172.16.0.1 table 1

#ip route add 172.16.1.1/24 via 172.16.1.1 table 2

9. Add default route in respective tables

#ip route add default via 210.211.251.189 table1

#ip route add default via 192.168.1.1 table2

10 Add natting rules

#iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

#iptables -t nat -A POSTROUTING -o eth2 -j MASQUEARDE

.

============================================================================================================================

failover Script :

12. Add failover script

#vi failover

#!/bin/bash

PATH=/sbin:/usr/bin:/bin;

gw1=210.211.251.189

gw2=192.168.1.1

gateway_1_down ()

{

echo " DOWN $gw1"

ip rule delete from 172.16.0.0/24 table gipl

ip rule delete from 172.16.1.0/24 table icenet

ip route delete default

route add -net 0.0.0.0 netmask 0.0.0.0 gw 210.211.251.1

ip route flush cache

iptables -t nat -F

iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE

service iptables save

service iptables restart

sleep 1m

failover_start

return

}

gateway_2_down ()

{

echo "DOWN $gw2"

ip rule delete from 172.16.0.0/24 table gipl

ip rule delete from 172.16.1.0/24 table icenet

ip route delete default

route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.1.1

ip route flush cache

iptables -t nat -F

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

service iptables save

service iptables restart

sleep 1m

failover_start

return

}

resume_gw ()

{

echo "starting sequence when both ISPs are up"

sh rules

echo "Rules Loaded"

sh routes

echo "Routes Loaded"

sh snat

echo "Natting Rules Loaded"

failover_start

return

}

failover_start ()

{

if ( ping -c5 -t5 $gw1 | grep -q "100% packet loss" ) ;

then

gateway_1_down

elif ( ping -c5 -t5 $gw2 | grep -q "100% packet loss" )

then

gateway_2_down

elif ( ping -c5 -t5 $gw1 | grep -q "0% packet loss" && ping -c5 -t5 $gw2 | grep -q "0% packet loss" )

then

{

echo "Both ISPs are up"

ip rule list > /etc/rules

}

if( diff -b /etc/rules /etc/sysconfig/rules );

then

failover_start

else

echo "Calling Function Resume_gw"

resume_gw

fi

return

fi

}

failover_start

Indice de la Documentación




Products and Services Linux LiveCD Router | Hotspot Server | Media Server | Money Back Guarantee | Printed Book Format | Online Documentation |
Follow us on Twitter | ba.net



Contact us info@easylivecd.com
© EasyLiveCD.com, FonoSIP.com, WiFi.com.ar, BA.NET
>