[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

balanceo de carga



Hola listreros
tengo la siguiente situacion: tengo un servidor con cuatro placas de red:
eth0 para la red local
eth1 conectada a un router adsl 2.5M
eth2 conectada a otro router adsl de 2M
eth3 conectada a una linea dedicada de 512K

lo que estoy intentando de hacer es balaceo de carga entre los dos
adsl. entonces cree el siguiente scripts
###########################################
### SETEO DE VARIABLES
###########################################

IF_LAN=eth0                     # placa red local
IF_ADSL1=eth1                   # placa adsl1
IF_ADSL2=eth2                   # placa adsl2
IF_INTEGRA=eth3                 # placa integra (uso exclusivo para web)

IP_LAN=10.1.1.1                 # ip de la red local
IP_ADSL1=10.0.1.3               # ip de router adsl1
IP_ADSL2=10.0.2.3               # ip de router adsl2
IP_INTEGRA=200.43.126.130       # la direccion ip de eth3 (router)

GW_ADSL1=10.0.1.1               # ip del router de adsl1 (gateway)
GW_ADSL2=10.0.2.1               # ip del router de adsl2 (gateway)
GW_INTEGRA=200.43.126.129       # ip del router de integra (gateway)

MASK_LAN=16
MASK_ADSL1=24
MASK_ADSL2=24
MASK_INTEGRA=25

NET_LAN=10.1.0.0/$MASK_LAN      # netmask de red local
NET_ADSL1=10.0.1.0/$MASK_ADSL1          # netmask de adsl1
NET_ADSL2=10.0.2.0/$MASK_ADSL2          # netmask de adsl2
NET_INTEGRA=200.43.126.128/$MASK_INTEGRA        # netmask de integra

BRD_ADSL1=10.0.1.255
BRD_ADSL2=10.0.2.255
BRD_INTEGRA=200.43.126.255

###############################################
### AJUSTES DE PARAMETROS DE RUTEO
###############################################

echo 30 > /proc/sys/net/ipv4/route/gc_interval
echo 100 > /proc/sys/net/ipv4/route/gc_elasticity
echo 100 > /proc/sys/net/ipv4/route/gc_timeout
echo 5 > /proc/sys/net/ipv4/route/max_delay
echo 4096 > /proc/sys/net/ipv4/route/max_size
echo 2048 > /proc/sys/net/ipv4/route/gc_thresh

###############################################
#CREA LAS TABLAS EN RT_TABLES
###############################################

echo "# reserved values"     > /etc/iproute2/rt_tables
echo "255       local"      >> /etc/iproute2/rt_tables
echo "254       main"       >> /etc/iproute2/rt_tables
echo "253       default"    >> /etc/iproute2/rt_tables
echo "0         unspec"     >> /etc/iproute2/rt_tables
echo "#"                    >> /etc/iproute2/rt_tables
echo "# local"              >> /etc/iproute2/rt_tables
echo "#"                    >> /etc/iproute2/rt_tables
echo "#1        inr.ruhep"  >> /etc/iproute2/rt_tables
echo "201       T_ADSL1"    >> /etc/iproute2/rt_tables
echo "202       T_ADSL2"    >> /etc/iproute2/rt_tables
echo "203       T_INTEGRA"  >> /etc/iproute2/rt_tables
echo "222       T_BALANCEO" >> /etc/iproute2/rt_tables
#######################################################

#################################################
#         CONFIGURA LAS PLACAS DE RED
#################################################
ip link set $IF_LAN up
ip addr add $IP_LAN/$MASK_LAN brd + dev $IF_LAN

ip link set $IF_ADSL1 up
ip addr flush dev $IF_ADSL1
ip addr add $IP_ADSL1/$MASK_ADSL1 brd $BRD_ADSL1 dev $IF_ADSL1

ip link set $IF_ADSL2 up
ip addr flush dev $IF_ADSL2
ip addr add $IP_ADSL2/$MASK_ADSL2 brd $BRD_ADSL2 dev $IF_ADSL2

ip link set $IF_INTEGRA up
ip addr flush dev $IF_INTEGRA
ip addr add $IP_INTEGRA/$MASK_INTEGRA brd $BRD_INTEGRA dev $IF_INTEGRA

###############################################
# BORRA LA RUTA POR DEFAULT DE MAIN
###############################################
ip route del default table main

#################################
# BORRA TODAS LAS REGLAS
################################
ip rule del from 10.0.1.0/24 lookup T_ADSL1 ## regla particular de red
ip rule del from 10.0.2.0/24 lookup T_ADSL2 ## regla particular de red2
ip rule del prio 222 ## regla virtual de balanceo
ip rule del prio 50 ## regla main
ip rule del from 200.43.126.130 lookup T_INTEGRA
ip rule del from 200.43.126.130 lookup T_INTEGRA
ip rule del from 200.43.126.130 lookup T_INTEGRA

###########################################
### BORRAR TABLAS DE RUTEO
###########################################

ip route flush cache
ip route flush default
ip route flush 201              # tabla ADSL1
ip route flush 202              # tabla ADSL2
ip route flush 203              # tabla INTEGRA
ip route flush 222              # tabla balanceo

###########################################
### CREACION DE RUTAS DE LA RED LOCAL
###########################################

route add 127.0.0.1 lo
route add $IP_LAN $IF_LAN

###########################################
### CREAR RUTAS EN LA TABLA MAIN
###########################################

ip route add $NET_LAN   dev $IF_LAN src $IP_LAN
ip route add $NET_ADSL1 dev $IF_ADSL1 src $IP_ADSL1
ip route add $NET_ADSL2 dev $IF_ADSL2 src $IP_ADSL2
ip route add $NET_INTEGRA dev $IF_INTEGRA src $IP_INTEGRA


###########################################
### CREAR TABLAS DE LAS SALIDAS A INTERNET
###########################################

ip route add $NET_ADSL1 dev $IF_ADSL1 src $IP_ADSL1 table T_ADSL1
ip route add default via $GW_ADSL1 dev $IF_ADSL1 src $IP_ADSL1 proto
static table T_ADSL1
ip route append prohibit default table T_ADSL1 metric 1 proto static

ip route add $NET_ADSL2 dev $IF_ADSL2 src $IP_ADSL2 table T_ADSL2
ip route add default via $GW_ADSL2 dev $IF_ADSL2 src $IP_ADSL2 proto
static table T_ADSL2
ip route append prohibit default table T_ADSL2 metric 1 proto static

ip route add $NET_INTEGRA dev $IF_INTEGRA src $IP_INTEGRA table T_INTEGRA
ip route add default via $GW_INTEGRA table T_INTEGRA

########################################################
### ENCAMINAMOS LOS PAQUETES - CREACION DE LAS REGLAS
########################################################

ip rule add prio 50                     table main
ip rule add prio 201 from $NET_ADSL1    table T_ADSL1
ip rule add prio 202 from $NET_ADSL2    table T_ADSL2
ip rule add prio 222                    table T_BALANCEO
ip rule add          from $IP_INTEGRA   table T_INTEGRA

###########################################
### CREAR BALANCEO DE CARGA ENTRE ADSL1 Y 2
###########################################

ip route add default table T_BALANCEO proto static \
nexthop via $GW_ADSL1 dev $IF_ADSL1 \
nexthop via $GW_ADSL2 dev $IF_ADSL2
##############################################


el balanceo no funciona del todo bien cada tanto (unos minutos)
pareceria como si se cayera la conexion y despues de un minuto todo
vuelve a funcionar.
estuve buscando en gooogle pero no encontre nada al respecto.
otro de los problemas que tengo con el balanceo es que cuando uno de
los enlaces adsl se desconecta automaticamente el servidor deja de
reenviar los paquetes a internet, como si los dos enlaces estarian
caidos, es decir que el balanceo no tiene tolerancia a fallos.

alguien me podria decir a que se puede deber este problema.
ya hace bastante que ando con este problema y la verdad que lei todos
los tutoriales que encontre y no logro encontrar la solucion.

help!!!!!!!!!!!!!!!!!!!!!

---
Saludos, Cristian



Reply to: