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

balance carga 2 entradas internet



hola listeros.
hece timpo tengo un problema con un script que trata de generar un
balance de carga sobre 2 entradas de internet.
su fin es lograr estabilidad a mis salidas ya que es normal el corte
de cualquiera de los 2 puntos de la red. (internet-wan)
para esto estoy trabajando con iproute
googleando encontre
http://www.esdebian.org/staticpages/index.php?page=20040921021605992
es mi caso :) pero no logro dar con el objetivo. :(
mi scrip es:
**********************************************
#!/bin/bash
ip addr flush lo
ip link set lo down
ip addr flush eth0
ip link set eth0 down
ip addr flush eth1
ip link set eth1 down
ip addr flush eth2
ip link set eth2 down

ip addr add 127.0.0.1/8 dev lo
ip link set lo up

#Interfaz eth0 (conexion LAN)
ip addr add 192.168.20.2/24 dev eth0 #10.15.8.102/16
ip link set eth0 up

#Interfaz eth1 (conexion ADSL 2 Mbps.)
ip addr add 192.168.178.108/24 dev eth1 #10.69.69.1/24
ip link set eth1 up

#Interfaz eth2 (conexion ADSL 512 Kbps.)
ip addr add 192.168.10.99/24 dev eth2 #10.69.70.1/24
ip link set eth2 up

#Establecimiento de las rutas
ip route flush default
#Rutas estáticas.
route add -host 127.0.0.1/32 dev lo
route add -net 192.168.20.0/24 dev eth0 #10.15.0.0/16
route add -net 192.168.178.0/24 gw 192.168.178.20 dev eth1
#10.69.69.0/24 gw 10.69.69.1 dev eth1
route add -net 192.168.10.0/24 gw 192.168.10.1 dev eth2 #10.69.70.0/24
gw 10.69.70.1 dev eth2
#Rutas a hosts especificos
#route add -host 10.16.1.1 gw 10.15.8.10 dev eth0
#route add -host 10.16.1.2 gw 10.15.8.10 dev eth0
#route add -host 10.129.255.193 gw 10.15.8.10 dev eth0
#Rutas
echo "Ajustando rutas..."
IF0="eth0"
IF1="eth1"
IF2="eth2"
IP0="192.168.20.2" #10.15.8.102
IP1="192.168.178.108" #10.69.69.1
IP2="192.168.10.99" #10.69.70.1
P1="192.168.178.20" #10.69.69.8
P2="192.168.10.1" #10.69.70.8
P0_NET="192.168.20.0" #10.15.0.0
P1_NET="192.168.178.0" #10.69.69.0
P2_NET="192.168.10.0" #10.69.70.0

#Interfaz 0
ip route add $P0_NET dev $IF0
ip route add $P0_NET dev $IF0
ip route add $P0_NET dev $IF0 src $IP0
ip route add $P1_NET dev $IF1 table T1
ip route add default via $P1 table T1
ip route add $P2_NET dev $IF2 table T2
ip route add default via $P2 table T2
ip route add $P1_NET dev $IF1 src $IP1
ip route add $P2_NET dev $IF1 src $IP2
#LA REGLA MAGICA QUE BALANCEA ENTRE LAS 2 LINEAS
echo "test1"
ip route add default equalize scope global nexthop via $P2 dev $IF2
weight 1 nexthop via $P1 dev $IF1 weight 2
echo "fin test1"
ip rule add from $IP1 table T1
ip rule add from $IP2 table T2
**********************************************
los errores que me tira son:
SIOCADDRT: La red es inaccesible
SIOCADDRT: La red es inaccesible
Ajustando rutas...
RTNETLINK answers: File exists
RTNETLINK answers: File exists
Error: argument "T1" is wrong: "table" value is invalid

Error: argument "T1" is wrong: "table" value is invalid

Error: argument "T2" is wrong: "table" value is invalid

Error: argument "T2" is wrong: "table" value is invalid

test1
RTNETLINK answers: Network is unreachable
fin test1
Error: argument "T1" is wrong: invalid table ID

Error: argument "T2" is wrong: invalid table ID
**********************************************
uname -a
Linux lalala 2.6.18-4-686 #1 SMP Mon Mar 26 17:17:36 UTC 2007 i686 GNU/Linux
con respecto al link anterior creo que no es necesario compilar el kernel.

# ip route show
192.168.178.0 dev eth1  scope link  src 192.168.178.108
192.168.10.0 dev eth1  scope link  src 192.168.10.99
192.168.20.0 dev eth0  scope link
127.0.0.1 dev lo  scope link
192.168.20.0/24 dev eth0  scope link

la tabla de ruteo no es correcta..
**********************************************
datos de mi red
eth0 = red local
eth0_ip = 192.168.20.2  netmask 255.255.255.0
eth1= wan adsl
eth1_ip = 192.168.178.108 netmask 255.255.255.0
eth1_gw = 192.168.178.20
eth2= wan adsl
eth2_ip = 192.168.10.99 netmask 255.255.255.0
eth2_gw = 192.168.10.1

dns = por suerte un externo que anda de 10 ;)

agradeceria ayuda con este script o alguna recomendacion paralela a
iproute ya que entiendo nadaa y no se que hacer.
por anticipado muchas gracias



Reply to: