Equipos y materiales > Openwrt & LEDE

[Tutorial] Multiwan con HG556a (VLANs)

(1/10) > >>

emeryth:
[Manual] Multiwan con HG-556a


En definicion un multiwan es util cuando tenemos 2 o más entradas wan (internet o enrutado a otras redes) y queremos que una unica red utilice las 2 o más salidas wan, de una manera determinada.  Podemas configurarlo para que al caer una de las wan la otra empiese a trabajar. O podemos configurarlo para que se repartan el trabajo entre ellas.

OJO esto no aumentara el anchuo de banda. Si tenemos una entrada de internet de 10 Mbps y otra de 6 Mbps no tendremops un ancho de banda de de 16 Mbps. Me esplico, sí quieres bajar un archivo ISO de una distribucion linux por descarga directa (unica fuente). Solo podras bajarlo por una sola wan, ya sea por la de 10 o por la de 6 depende de cómo lo configures. Pero si quieres bajar el mismo archivo por un enlace torrents (muchas fuentes) podras utilizar las 2 wan al tiempo porque se reparten las fuentes. Dando como resultado una descarga que se acerca mucho a los 16 Mbps (esto tiene muchas variables)

La manera de realizar el multiwan es dividiendo en lan virtuales el router, el router HG-556 nombra a su switch como “eth0”, el contred 5361 los nombra “eth1”, algunos router no se les puede dividir el switch en lan virtuale (vlan).

En nuestro ejemplo tendremos 1 puerto lan (conector Lan1), 3 puertos wan (los otros 3 conectores del router, lan2 al lan 4), y la wifi configurada como cliente para ser una cuarta entrada wan (wwan)


--- Código: ---eth0 (switch)
Vlan 0               Vlan 1                      Vlan 2                         Vlan 3
(puerto)0                 1                                 2                           3
eth0.0              eth0.1                     eth0.2                         eth0.3
Lan1 (fisico)       Lan2                              Lan3                          Lan4
Lan                      Wan2                             Wan3                         Wan4
             XX:XX:XX:XX:18:XX XX:XX:XX:XX:28:XX       XX:XX:XX:XX:38:XX

--- Fin del código ---


Para ejecutar multiwan debes tener instalado los siguientes paquetes: Iptables, ip, iptables-mod-conntrack, iptables-mod-conntrack-extra, iptables-mod-ipopt, kmod-ipt-ipopt
Multiwan, luci-app-multiwan, nano. Esta compilacion los tiene instalado.

https://docs.google.com/open?id=0ByLHkumzyj7idm1mdlViR1k0dms

Nota la mayoria de comando  estan basados en uci, por lo tanto deben ejecutarse desde Putty (ventana de comandos del SSH).

Configuracion del archivo etc/config/network

[spoiler]config interface 'loopback'
   option ifname 'lo'
   option proto 'static'
   option ipaddr '127.0.0.1'
   option netmask '255.0.0.0'

config switch 'eth0'
   option enable '1'
   option reset '1'
   option enable_vlan '1'

config switch_vlan
   option device 'eth0'
   option vlan '0'
   option ports '0 5t'

config switch_vlan
   option device 'eth0'
   option vlan '1'
   option ports '1 5t'

config switch_vlan
   option device 'eth0'
   option vlan '2'
   option ports '2 5t'

config switch_vlan
   option device 'eth0'
   option vlan '3'
   option ports '3 5t'

config interface 'lan'
   option type 'bridge'
   option proto 'static'
   option netmask '255.255.255.0'
   option ifname 'eth0.0'
   option ipaddr '192.168.30.1'
   option nat '1'

config interface 'wan2'
   option ifname 'eth0.1'
   option proto 'dhcp'
   option macaddr 'XX:XX:XX:XX:18:XX '

config interface 'wan3'
   option ifname 'eth0.2'
   option proto 'dhcp'
   option macaddr 'XX:XX:XX:XX:28:XX '

config interface 'wan4'
   option ifname 'eth0.3'
   option proto 'dhcp'
   option macaddr 'XX:XX:XX:XX:38:XX '

config interface 'wwan'
   option proto 'dhcp'
[/spoiler]


Las subredes entre la las wan y la lan no se pueden repetir. Por eso la interface lan tiene una subred algo dificil de encontrar en el entorno. Se puede fijar una ip a cada wan pero es más flexible nombralas por una mac cualquiera, pero dirente entre ellas.  

Nota: hg556a no permite la conexión ADSL por lo que este tipo de wan no es posible hasta el momento.

Comandos uci para el archivo network, debes poner los numero de la MAC que te apetesca, y una subred en la lan. Todo lo demas puede ser igual para el router hg556a

[spoiler]uci set network.eth0=switch
uci set network.eth0.enable=1
uci set network.eth0.reset=1
uci set network.eth0.enable_vlan=1

uci add network switch_vlan
uci set network.@switch_vlan[-1].device=eth0
uci set network.@switch_vlan[-1].vlan=0
uci set network.@switch_vlan[-1].ports="0 5t"

uci add network switch_vlan
uci set network.@switch_vlan[-1].device=eth0
uci set network.@switch_vlan[-1].vlan=1
uci set network.@switch_vlan[-1].ports="1 5t"

uci add network switch_vlan
uci set network.@switch_vlan[-1].device=eth0
uci set network.@switch_vlan[-1].vlan=2
uci set network.@switch_vlan[-1].ports="2 5t"

uci add network switch_vlan
uci set network.@switch_vlan[-1].device=eth0
uci set network.@switch_vlan[-1].vlan=3
uci set network.@switch_vlan[-1].ports="3 5t"

uci set network.lan=interface
uci set network.lan.ifname=eth0.0
uci set network.lan.type=bridge
uci set network.lan.proto=static
uci set network.lan.netmask=255.255.255.0
uci set network.lan.ipaddr=192.168.30.1
uci set network.lan.nat=1

uci set network.wan2=interface
uci set network.wan2.ifname=eth0.1
uci set network.wan2.proto=dhcp
uci set network.wan2.macaddr=XX:XX:XX:XX:18:XX

uci set network.wan3=interface
uci set network.wan3.ifname=eth0.2
uci set network.wan3.proto=dhcp
uci set network.wan3.macaddr=XX:XX:XX:XX:28:XX

uci set network.wan4=interface
uci set network.wan4.ifname=eth0.3
uci set network.wan4.proto=dhcp
uci set network.wan4.macaddr=XX:XX:XX:XX:38:XX

uci set network.wwan=interface
uci set network.wwan.proto=dhcp
uci commit
[/spoiler]

configuracion de /etc/config/wireless

El wireless apunta a una red que nos brinda internet (nos sirve de wan) la configuracion es la misma que para poner el router como cliente. Esta configuracion es mas facil realizarla desde luci, despues de un escaneo con la wifi.

[spoiler]config wifi-device 'radio0'
   option type 'mac80211'
   option macaddr´XX:XX:XX:XX:XX:XX´
   option hwmode '11ng'
   option htmode 'HT20'
   list ht_capab 'SHORT-GI-40'
   list ht_capab 'TX-STBC'
   list ht_capab 'RX-STBC1'
   list ht_capab 'DSSS_CCK-40'
   option channel '11'
   option disabled '0'

config wifi-iface
   option device 'radio0'
   option bssid ‘XX:XX:XX:XX:XX:XX’
   option mode 'sta'
   option network 'wwan'
   option ssid 'nombre de la red’
   option encryption 'tipo de encriptacion”
   option key 'clave'
[/spoiler]

comandos uci para el wireless

[spoiler]uci set wireless.radio0.channel=11
uci set wireless.radio0.hwmode=11ng
uci set wireless.radio0.disabled=0
uci set wireless.@wifi-iface[0].mode=sta
uci set wireless.@wifi-iface[0].network=wwan
uci set wireless.@wifi-iface[0].ssid=nombre de la red
uci set wireless.@wifi-iface[0].encryption=tipo de encriptacion
uci set wireless.@wifi-iface[0].key=clave
uci commit
[/spoiler]

Configuracion de archivo /etc/config/firewall

Las cosas a configurar en este archivo son muy pocas, se basan en agrupar las interfaces es 2 grupos o zonas. Una zona lan donde se refiere a la interfac lan, y una zona wan donde se refieren a las interfaces wwan, wan2, wan3, wan4 que hemos creado en el archivo network.

[spoiler]config defaults
   option syn_flood '1'
   option input 'ACCEPT'
   option output 'ACCEPT'
   option forward 'REJECT'

config zone
   option name 'lan'
   option network 'lan'
   option input 'ACCEPT'
   option output 'ACCEPT'
   option forward 'REJECT'

config zone
   option name 'wan'
   option input 'REJECT'
   option output 'ACCEPT'
   option forward 'REJECT'
   option masq '1'
   option mtu_fix '1'
   option network 'wan wwan wan2 wan3 wan4'

config forwarding
   option src 'lan'
   option dest 'wan'
[/spoiler]

en los comandos uci solo se tiene que alterar 2 parametros todos los demas pueden quedar como bienen.


--- Código: ---uci set firewall.@zone[0].network=lan
uci set firewall.@zone[1].network="wan wwan wan2 wan3 wan4"
uci commit

--- Fin del código ---

Configuracion del archivo /etc/config/multiwan

[spoiler]config multiwan 'config'
   option enabled '1'
   option default_route 'fastbalancer'

config interface 'wwan'
   option weight '10'
   option health_interval '10'
   option icmp_hosts 'dns'
   option timeout '3'
   option health_fail_retries '3'
   option health_recovery_retries '5'
   option failover_to 'fastbalancer'
   option dns 'auto'

config interface 'wan2'
   option weight '10'
   option health_interval '10'
   option icmp_hosts 'dns'
   option timeout '3'
   option health_fail_retries '3'
   option health_recovery_retries '5'
   option failover_to 'fastbalancer'
   option dns 'auto'

config interface 'wan3'
   option weight '10'
   option health_interval '10'
   option icmp_hosts 'dns'
   option timeout '3'
   option health_fail_retries '3'
   option health_recovery_retries '5'
   option failover_to 'fastbalancer'
   option dns 'auto'

config interface 'wan4'
   option weight '10'
   option health_interval '10'
   option icmp_hosts 'dns'
   option timeout '3'
   option health_fail_retries '3'
   option health_recovery_retries '5'
   option failover_to 'fastbalancer'
   option dns 'auto'
[/spoiler]

La primera parte activa el multiwan, y configura la forma de controlar los paquetes. Si al probar la red es inestable, puedes cambiar el metodo en que multiwan controla los paquetes cambiando el valor de failover_to que puede ser fastbalancer (Balanceado con netfilter) o balancer (Balanceado con iproute2)

Las otras partes definen los nombres de las interface wan, deben ser los mismos nombres que los referidos en el archivo network. Solo es importante el nombre de la interface los demas datos de cada columna pueden quedarse como estan.

Comandos uci para multiwan

[spoiler]uci set multiwan.config.enabled=1
uci set multiwan.config.default_route=fastbalancer

uci delete multiwan.wan
uci delete multiwan.wan2

uci set multiwan.wwan=interface
uci set multiwan.wwan.weight=10
uci set multiwan.wwan.health_interval=10
uci set multiwan.wwan.icmp_hosts=dns
uci set multiwan.wwan.timeout=3
uci set multiwan.wwan.health_fail_retries=3
uci set multiwan.wwan.health_recovery_retries=5
uci set multiwan.wwan.failover_to=fastbalancer
uci set multiwan.wwan.dns=auto

uci set multiwan.wan2=interface
uci set multiwan.wan2.weight=10
uci set multiwan.wan2.health_interval=10
uci set multiwan.wan2.icmp_hosts=dns
uci set multiwan.wan2.timeout=3
uci set multiwan.wan2.health_fail_retries=3
uci set multiwan.wan2.health_recovery_retries=5
uci set multiwan.wan2.failover_to=fastbalancer
uci set multiwan.wan2.dns=auto

uci set multiwan.wan3=interface
uci set multiwan.wan3.weight=10
uci set multiwan.wan3.health_interval=10
uci set multiwan.wan3.icmp_hosts=dns
uci set multiwan.wan3.timeout=3
uci set multiwan.wan3.health_fail_retries=3
uci set multiwan.wan3.health_recovery_retries=5
uci set multiwan.wan3.failover_to=fastbalancer
uci set multiwan.wan3.dns=auto

uci set multiwan.wan4=interface
uci set multiwan.wan4.weight=10
uci set multiwan.wan4.health_interval=10
uci set multiwan.wan4.icmp_hosts=dns
uci set multiwan.wan4.timeout=3
uci set multiwan.wan4.health_fail_retries=3
uci set multiwan.wan4.health_recovery_retries=5
uci set multiwan.wan4.failover_to=fastbalancer
uci set multiwan.wan4.dns=auto
uci commit
[/spoiler]

otros comandos uci para configurar la zona horaria y el idioma de luci

[spoiler]uci set system.@system[0].hostname=openwrt
uci set system.@system[0].zonename=Europe/Madrid
uci set system.@system[0].timezone=CET-1CEST,M3.5.0,M10.5.0/3
uci set system.@system[0].conloglevel=8
uci set system.@system[0].Cronloglevel=8
uci set luci.main.lang=es
uci commit
[/spoiler]

Esta parte debe copiarse de un solo tirón y pegarse en la ventana de comandos para que rellene el archivo firewall, esto configura los iptables para accesos a servicios y detección de ataques o escaneos

[spoiler]cat >> /etc/firewall.user << EOF      
iptables -I INPUT 1 -p tcp --tcp-flags ALL NONE -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix "Firewall> Null scan "
iptables -I INPUT 2 -p tcp --tcp-flags ALL NONE -m recent --name blacklist_60 --set -m comment --comment "Drop/Blacklist Null scan" -j DROP
iptables -I INPUT 3 -p tcp --tcp-flags ALL FIN,PSH,URG -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix "Firewall> XMAS scan "
iptables -I INPUT 4 -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix "Firewall> XMAS-PSH scan "
iptables -I INPUT 5 -p tcp --tcp-flags ALL ALL -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix "Firewall> XMAS-ALL scan "
iptables -I INPUT 6 -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -m recent --name blacklist_60 --set  -m comment --comment "Drop/Blacklist Xmas/PSH scan" -j DROP
iptables -I INPUT 7 -p tcp --tcp-flags ALL FIN,PSH,URG -m recent --name blacklist_60 --set  -m comment --comment "Drop/Blacklist Xmas scan" -j DROP
iptables -I INPUT 8 -p tcp --tcp-flags ALL ALL -m recent --name blacklist_60 --set  -m comment --comment "Drop/Blacklist Xmas/All scan" -j DROP
iptables -I INPUT 9 -p tcp --tcp-flags ALL FIN -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix "Firewall> FIN scan "
iptables -I INPUT 10 -p tcp --tcp-flags ALL FIN -m recent --name blacklist_60 --set  -m comment --comment "Drop/Blacklist FIN scan" -j DROP
iptables -I INPUT 11 -p tcp  -m multiport --dports 23,79 --tcp-flags ALL SYN -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix "Firewall>SYN scan trap:"
iptables -I INPUT 12 -p tcp  -m multiport --dports 23,79 --tcp-flags ALL SYN -m recent --name blacklist_180 --set -j DROP
iptables -I INPUT 13 -p udp  -m limit --limit 6/h --limit-burst 1 -m length --length 0:28 -j LOG --log-prefix "Firewall>0 length udp "
iptables -I INPUT 14 -p udp -m length --length 0:28 -m comment --comment "Drop UDP packet with no content" -j DROP
EOF
[/spoiler]

se aconseja un reboot.

emeryth:
hola chicos,

Al parecer este tema no despierta mucho interés, porque es poco útil o porque esta mal explicado si es el ultimo caso se espera feedback para mejorarlo.  :-\

jar229:
Yo creo que poca gente tiene 2 o más conexiones para poder sacar partido al multiwan.
Pero no te preocupes, que está perfectamente explicado ;) 

Enviado desde mi Cube U30GT ( Infected v. 1.3) usando Tapatalk 2

eq7mavala:
A mi me podria interesar, si fuera en plan cuando internet que lo recibo por LAN se pierda que conecte por 3G, pero no es lo mas habitual

Noltari:
Opino lo mismo que jar229.
Está bien explicado, pero no hay mucha gente que utilice multiwan.

Aunque está muy bien tenerlo como tuto "educativo" :D.

Saludos!

Navegación

[0] Índice de Mensajes

[#] Página Siguiente

Ir a la versión completa