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

problema con 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


###########################################################################
                                                SCRIPTS
###########################################################################
#!/bin/bash

###########################################
### 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)

NET_LAN=10.1.0.0/16		# netmask de red local
NET_ADSL1=10.0.1.0/24 		# netmask de adsl1
NET_ADSL2=10.0.2.0/24 		# netmask de adsl2
NET_INTEGRA=200.43.126.128/25	# netmask de integra


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

ip route flush cache
ip route flush default
ip route flush 252		# tabla ADSL1
ip route flush 251		# tabla ADSL2
ip route flush 250		# tabla INTEGRA


###########################################
### 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 table T_ADSL1

ip route add $NET_ADSL2 dev $IF_ADSL2 src $IP_ADSL2 table T_ADSL2
ip route add default via $GW_ADSL2 table T_ADSL2

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


###########################################
### ELEGIR RUTAS POR DEFECTO
###########################################

#ip route add default via $GW_ADSL1
#ip route add default via $GW_ADSL2


###########################################
### ENCAMINAMOS LOS PAQUETES
###########################################

ip rule add from $IP_ADSL1 	table T_ADSL1
ip rule add from $IP_ADSL2 	table T_ADSL2
ip rule add from $IP_INTEGRA 	table T_INTEGRA


###########################################
### AGREGAR DISTINTAS REDES EN TODAS LAS TABLAS
###########################################

ip  route add  127.0.0.0/8   	dev lo    	table   T_ADSL1
ip  route add  $NET_ADSL1       dev $IF_ADSL1 	table   T_ADSL1
ip  route add  $NET_ADSL2       dev $IF_ADSL2  	table   T_ADSL1
ip  route add  $NET_INTEGRA     dev $IF_INTEGRA table   T_ADSL1

ip  route add  127.0.0.0/8   	dev lo    	table   T_ADSL2
ip  route add  $NET_ADSL1       dev $IF_ADSL1 	table   T_ADSL2
ip  route add  $NET_ADSL2       dev $IF_ADSL2  	table   T_ADSL2
ip  route add  $NET_INTEGRA     dev $IF_INTEGRA table   T_ADSL2

ip  route add  127.0.0.0/8   	dev lo    	table   T_INTEGRA
ip  route add  $NET_ADSL1       dev $IF_ADSL1 	table   T_INTEGRA
ip  route add  $NET_ADSL2       dev $IF_ADSL2  	table   T_INTEGRA
ip  route add  $NET_INTEGRA     dev $IF_INTEGRA table   T_INTEGRA


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


ip route add equalize scope global \
nexthop via $GW_ADSL2 dev $IF_ADSL2 weight 1 onlink \
nexthop via $GW_ADSL1 dev $IF_ADSL1 weight 1 onlink

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



el balanceo parace funcionar (lo probe observando con iptraf), el
problema es que si un adsl se desconecta automaticamente dejo de tener
salida a internet.
ademas cuando intento hacer
ping www.google.com -I eth2 responde perfectamente, pero
ping www.google.com -I eth1 se queda colgado, lo unico que hace es
reslover el nombre de domonio y se queda colgado sin dar respuesta.

probe con modificar lo siguiente en el scripts


ip route add equalize scope global \
nexthop via $GW_ADSL1 dev $IF_ADSL1 weight 1 onlink \
nexthop via $GW_ADSL2 dev $IF_ADSL2 weight 1 onlink

y ahora la situacion es la siguiente

ping www.google.com -I eth1 responde perfectamente, pero
ping www.google.com -I eth2 se queda colgado, lo unico que hace es
reslover el nombre de domonio y se queda colgado sin dar respuesta.

alguien sabe a que se puede deber esto?
hay alguna forma de que al desconectarse un adsl siga teniendo acceso
a internet por el otro?


Espero que puedan ayudarme, desde ya muchas gracias

Saludos, Cristian



Reply to: