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

Re: Conectar Dos ADSL a un Equipo Linux





On Thu, May 7, 2009 at 9:01 PM, haldrik <haldrik@gmail.com> wrote:
Hola, estoy tratando de usar dos conexiones adsl en un mismo equipo con
debian lenny, la idea es hacer balanceo de carga. ADSL1 =512kbps y
ADSL2 =2048kbps
Luego de tener listo este balanceo vendría a hacer nat para la red local.

El script que tengo lo saqué del tutorial de LARTC que se supone que
debería funcionar,
si alguien lo ha hecho por favor una manito.

#!/bin/bash

# Creo las tablas, esto lo hago solo una vez
echo 200 T1 >> /etc/iproute2/rt_tables
echo 200 T2 >> /etc/iproute2/rt_tables

IF0="eth0" # Interface conectada a la LAN
IF1="eth1" # Interface conectada a ADSL1 Lenta
IF2="eth2" # Interface conectada a ADSL2 Rápida
IP0="192.168.1.1" # Ip de la LAN
IP1="10.1.0.1" # ip para IF1
IP2="10.1.1.1" # ip para IF2
P0_NET="192.168.1.0/24" # Red de la IP1
P1_NET="10.1.0.0/24" # Red de la IP2
P2_NET="10.1.1.0/24"
P1="10.1.0.1" # Gateway para ADSL1
P2="10.1.1.1" # Gateway para ADSL2

echo "Limpiando Reglas Anteriores..."
# Limpio las tablas T1 y T2
ip route flush table T1
ip route flush table T2

# Creo las tablas de rutas para las dos interfaces uplink
echo "Creo las rutas para cada tabla"
ip route add ${P1_NET} dev ${IF1} src ${IP1} table T1
ip route add default via ${P1} table T1
ip route add ${P2_NET} dev ${IF2} src ${IP2} table T2
ip route add default via ${P2} table T2

# Aseguro que cada red enviará sus solicitudes a la ip correcta
echo "Aseguro la ruta para cada interface e ip"
ip route add ${P1_NET} dev ${IF1} src ${IP1}
ip route add ${P2_NET} dev ${IF2} src ${IP2}

# Selecciono una ruta por defect
echo "Selecciono ruta por defecto"
ip route add default via ${P1}

# Creo dos reglas para que cada ip se fije a su tabla de rutas
echo "Creo reglas para cada tabla"
ip rule add from ${IP1} table T1
ip rule add from ${IP2} table T2

# Hago el balanceo 1 a 1
echo "Hago el balanceo"
ip route add default scope global nexthop via ${P1} dev ${IF1} weight 1 \
nexthop via ${P2} dev ${IF2} weight 3

Obtengo la siguiente salida:

edoras:~# ./doble-ruta
Limpiando Reglas Anteriores...
Nothing to flush.
Nothing to flush.
Creo las rutas para cada tabla
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
RTNETLINK answers: File exists
Aseguro la ruta para cada interface e ip
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
Selecciono ruta por defecto
RTNETLINK answers: File exists
Creo reglas para cada tabla
Hago el balanceo
RTNETLINK answers: File exists

Si listo las tablas T1 y T2 obtengo esto:
edoras:~# ip route list table T1
default via 10.1.0.1 dev eth1
edoras:~# ip route list table T2
default via 10.1.0.1 dev eth1

Si listo la tabla main obtengo esto:
edoras:~# ip route list table main
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.1
10.1.0.0/24 dev eth1  proto kernel  scope link  src 10.1.0.2
10.1.1.0/24 dev eth2  proto kernel  scope link  src 10.1.1.2
default via 10.1.1.1 dev eth2
default via 10.1.0.1 dev eth1

Si listo la tabla local obtengo esto:
edoras:~# ip route list table local
local 192.168.1.1 dev eth0  proto kernel  scope host  src 192.168.1.1
broadcast 192.168.1.0 dev eth0  proto kernel  scope link  src 192.168.1.1
broadcast 127.255.255.255 dev lo  proto kernel  scope link  src 127.0.0.1
local 10.1.0.2 dev eth1  proto kernel  scope host  src 10.1.0.2
broadcast 10.1.1.255 dev eth2  proto kernel  scope link  src 10.1.1.2
broadcast 10.1.0.0 dev eth1  proto kernel  scope link  src 10.1.0.2
broadcast 192.168.1.255 dev eth0  proto kernel  scope link  src 192.168.1.1
local 10.1.1.2 dev eth2  proto kernel  scope host  src 10.1.1.2
broadcast 127.0.0.0 dev lo  proto kernel  scope link  src 127.0.0.1
broadcast 10.1.1.0 dev eth2  proto kernel  scope link  src 10.1.1.2
broadcast 10.1.0.255 dev eth1  proto kernel  scope link  src 10.1.0.2
local 127.0.0.1 dev lo  proto kernel  scope host  src 127.0.0.1
local 127.0.0.0/8 dev lo  proto kernel  scope host  src 127.0.0.1

Si listo la tabla default no obtengo saludo.

Gracias por los aportes.
--
"LARGA VIDA Y PODEROSA."


--
To UNSUBSCRIBE, email to debian-user-spanish-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Tal vez no te interese pero la verdad es que Pfsense es una distro(FreeBSD) que hace lo que necesitas desde una web interface y lo hace de una manera muy sencilla y mas segura.

http://www.pfsense.org

echale un vistazo.

saludos.

--
"It is human nature to think wisely and act in an absurd fashion."

"Todo el desorden del mundo proviene de las profesiones mal o mediocremente servidas"

Reply to: