Mostrando entradas con la etiqueta wifi. Mostrar todas las entradas
Mostrando entradas con la etiqueta wifi. Mostrar todas las entradas

martes, 8 de julio de 2014

Balanceo de carga mejorado atravéz de multiples gateway (wan)

Con NAT y politicas de ruteos, trabaja con HTTPS, IM (mensajeros instantáneos) y grandes descargas
Considerar el siguiente diagrama de red
LoadBalancing.jpg
Configuración exportada del router:
/ ip address 
add address=1.1.1.50/24 network=1.1.1.0 broadcast=1.1.1.255 interface=Local comment="" \
    disabled=no 
add address=10.111.0.2/24 network=10.111.0.0 broadcast=10.111.0.255 interface=wlan2 \
    comment="" disabled=no 
add address=10.112.0.2/24 network=10.112.0.0 broadcast=10.112.0.255 interface=wlan1 \
    comment="" disabled=no
/ ip firewall mangle
add chain=prerouting in-interface=Local connection-state=new nth=1,1,0 \
    action=mark-connection new-connection-mark=odd passthrough=yes comment="" \
    disabled=no 
add chain=prerouting in-interface=Local connection-mark=odd action=mark-routing \
    new-routing-mark=odd passthrough=no comment="" disabled=no 
add chain=prerouting in-interface=Local connection-state=new nth=1,1,1 \
    action=mark-connection new-connection-mark=even passthrough=yes comment="" \
    disabled=no 
add chain=prerouting in-interface=Local connection-mark=even action=mark-routing \
    new-routing-mark=even passthrough=no comment="" disabled=no 
/ ip firewall nat 
add chain=srcnat connection-mark=odd action=src-nat to-addresses=10.111.0.2 \
    to-ports=0-65535 comment="" disabled=no 
add chain=srcnat connection-mark=even action=src-nat to-addresses=10.112.0.2 \
    to-ports=0-65535 comment="" disabled=no 
/ ip route 
add dst-address=0.0.0.0/0 gateway=10.111.0.1 scope=255 target-scope=10 routing-mark=odd \
    comment="" disabled=no 
add dst-address=0.0.0.0/0 gateway=10.112.0.1 scope=255 target-scope=10 routing-mark=even \
    comment="" disabled=no 
add dst-address=0.0.0.0/0 gateway=10.112.0.1 scope=255 target-scope=10 comment="" \
    disabled=no

Explicación

Primero mostramos el código y luego explicamos que es lo que hace.

Mangle

/ ip address 
add address=1.1.1.50/24 network=1.1.1.0 broadcast=1.1.1.255 interface=Local comment="" \
    disabled=no 
add address=10.111.0.2/24 network=10.111.0.0 broadcast=10.111.0.255 interface=wlan2 \
    comment="" disabled=no 
add address=10.112.0.2/24 network=10.112.0.0 broadcast=10.112.0.255 interface=wlan1 \
    comment="" disabled=no
El router tiene los interfaces de subidas (wan) con la dirección IP 10.111.0.2/24 y 10.112.0.2/24. La interface LAN tiene el nombre "Local" y la dirección ip 1.1.1.50/24.

/ ip firewall mangle

add chain=prerouting in-interface=Local connection-state=new nth=1,1,0 \
    action=mark-connection new-connection-mark=odd passthrough=yes comment="" \
    disabled=no 

Primero tomamos cada segundo paquete que establece una nueva sesión (nota connection-state=new) y marcamos con marca coneccion "impar". Consecuentemente todos los sucesivos paquetes siguientes de la misma sesión llevarán la marca conección "impar". Notar que estamos pasando esos paquetes a la segunda regla (passtrough=yes) par poner la marca de routeo en esos paquetes adicionando a la marca conección.
add chain=prerouting in-interface=Local connection-mark=odd action=mark-routing \
    new-routing-mark=odd passthrough=no comment="" disabled=no 
La regla anterior pone la marca de routing "impar" en todos los paquetes pertenecientes a la conección "impar" y para de procesar todos los otros mangles en la cadena prerouting para esos paquetes.
add chain=prerouting in-interface=Local connection-state=new nth=1,1,1 \
    action=mark-connection new-connection-mark=even passthrough=yes comment="" \
    disabled=no 
add chain=prerouting in-interface=Local connection-mark=even action=mark-routing \
    new-routing-mark=even passthrough=no comment="" disabled=no 
Esas reglas son las mismas para la mitad restante del tráfico como las primeras dos reglas para la primer mitad del tráfico.
El código anterior hace que cada nueva conección que se inicia a travéz del router desde la red local será marcado como "impar" o "par" con ambas marcas de routing y conección.

NAT

/ ip firewall nat 
add chain=srcnat connection-mark=odd action=src-nat to-addresses=10.111.0.2 \
    to-ports=0-65535 comment="" disabled=no 
add chain=srcnat connection-mark=even action=src-nat to-addresses=10.112.0.2 \
    to-ports=0-65535 comment="" disabled=no 

Routing

/ ip route 
add dst-address=0.0.0.0/0 gateway=10.111.0.1 scope=255 target-scope=10 routing-mark=odd \
    comment="" disabled=no 
add dst-address=0.0.0.0/0 gateway=10.112.0.1 scope=255 target-scope=10 routing-mark=even \
    comment="" disabled=no 
add dst-address=0.0.0.0/0 gateway=10.112.0.1 scope=255 target-scope=10 comment="" \
    disabled=no comment="gateway for the router itself"
Para todo el tráfico marcado "impar" (consecuentemente teniendo 10.111.1.0.2 como dirección origen traducida) usamos 10.111.0.1 como gateway. De la misma manera todo el tráfico marcado "par" es ruteada por el gateway 10.112.0.1. Finalmente, tenemos una entrada adicional especificando el trafico del router mismo (tráfico sin marcas de routing) deberían ir por el gateway 10.112.0.1.

miércoles, 4 de mayo de 2011

MIKROTIK, configuracion inicial


Conectar el Mikrotik por medio de un cable utp directo a la entrada Lan => Eth1 y la salida de la placa de red de la Pc.


Descargar e instalar los utilitarios  NeighborViever.exe y Winbox.exe




Ingresar al sistema
User: admin
Pasword:

Usuario=  admin y el pasword dejarlo en blanco



VER EN QUE ESTADO ESTAN LAS INTERFACES, PUES PUEDEN ESTAR DESABILITADAS.

[admin@MikroTik] > int
[admin@MikroTik] interface> pr
Flags: X - disabled, D - dynamic, R - running
 #    NAME                                    TYPE             RX-RATE    TX-RATE    MTU 
 0  R ether1                                  ether            0          0          1500
 1  X ether2                                  ether            0          0          1500
 [admin@MikroTik] interface>


SI POR CASUALIDAD HAY ALGUNA INTERFACE CON UNA “X” COM EN EL CASO DE LA INTERFACE ether2 HAY QUE HABILITARLA DE LA SIG. MANERA.

[admin@MikroTik] interface> enable 1
[admin@MikroTik] interface> pr
Flags: X - disabled, D - dynamic, R - running
 #    NAME                                    TYPE             RX-RATE    TX-RATE    MTU 
 0  R ether1                                  ether            0          0          1500
 1  R ether2                                  ether            0          0          1500
 [admin@MikroTik] interface>

ASIGNAR LAS IP A CADA INTERFACE.
EN CASO DE SER  IP DINAMICA :
[admin@MikroTik] > ip
[admin@MikroTik] > ip>dhcp-client
[admin@MikroTik] > ip dhcp-client>add interface=ether1 disabled=no
[admin@MikroTik] > ip dhcp-client>pr

O EN CASO DE SER IP FIJA:
[admin@MikroTik] > ip
[admin@MikroTik] ip> add
 [admin@MikroTik] ip address> add address  217.149.158.214/30   interface ether1 ( La ip asignada por el ISP)
[admin@MikroTik] ip address> pr

 [admin@MikroTik] > ip
[admin@MikroTik] ip> add
 [admin@MikroTik] ip address> add address 192.168.0.1/24   interface ether2 ( O el rango de ip´s que prefiera para la red privada)
[admin@MikroTik] ip address> pr
Flags: X - disabled, I - invalid, D - dynamic
 #   ADDRESS            NETWORK         BROADCAST       INTERFACE
0   217.149.158.214/30   217.149.158.213 217.149.158.216   ether2  
 1   192.168.0.1/24     192.168.0.0     192.168.0.255   ether1  
[admin@MikroTik] ip address>


CREAR EL DEFAULT GATEWAY

[admin@MikroTik] > ip   
[admin@MikroTik] ip> route
[admin@MikroTik] ip route> add dst-address 0.0.0.0/0 gateway 217.149.158.213 (la gateway del > dhcp-client >print detail)
[admin@MikroTik] ip route> pr
Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf
 #     DST-ADDRESS        PREFSRC         G GATEWAY         DISTANCE INTERFACE
0 ADC 192.168.0.0/24     192.168.0.1                                                                          ether1  
1 ADC 200.222.35.32/30   200.222.35.33                                                                   ether2  
2 A S 0.0.0.0/0                                                    r 200.222.35.34                                   ether2  
[admin@MikroTik] ip route>

UNA VES REALIZADO ESTO, YA SE DEBERIA PODER HACER UN PING DESDE EL ROUTER A LA PC 192.168.0.3 Y A CUALQUIER IP DE INTERNET. (PROBARLO PARA CONFIRMAR QUE AMBAS INTERFACES ESTAN FUNCIONANDO CORRECTAMENTE)



CREAR EL NAT PARA PODER COMPARTIR INTERNET EN LA RED INTERNA Y QUE LAS MISMAS PUEDAN NAVEGAR.


[admin@MikroTik] > ip
[admin@MikroTik] ip> fir
[admin@MikroTik] ip firewall> nat
[admin@MikroTik] ip firewall nat>
[admin@MikroTik] ip firewall nat> add chain=srcnat out-interf=ether2 action=masquerade
[admin@MikroTik] ip firewall nat> pr
Flags: X - disabled, I - invalid, D - dynamic
 0   chain=srcnat out-interface=ether2 action=masquerade
[admin@MikroTik] ip firewall nat>

CONFIGURAR EL SERVICIO DE CACHE DE DNS

[admin@MikroTik] ip> ..
[admin@MikroTik] > ip
[admin@MikroTik] ip> dns
[admin@MikroTik] ip dns> pr
            primary-dns: 0.0.0.0
          secondary-dns: 0.0.0.0
  allow-remote-requests: no
             cache-size: 2048KiB
          cache-max-ttl: 1w
             cache-used: 16KiB

COLOCAR LAS IP DE VUESTRO PROVEDOR EN LUGAR DE LAS DE EJEMPLO

 [admin@MikroTik] ip dns> set primary-dns=217.15.32.2 secondary-dns=200.45.191.35 allow-re
mote=yes  

[admin@MikroTik] ip dns> pr
            primary-dns: 80.58.0.33
          secondary-dns: 80.58.0.97
  allow-remote-requests: yes
             cache-size: 2048KiB
          cache-max-ttl: 1w
             cache-used: 16KiB
[admin@MikroTik] ip dns>

PARA ASIGNAR IP POR DHCP

/ip dhcp-server setup


SI A LA PC QUE TENES CONECTADA EN LA RED INTERNA CON LA IP 192.168.0.3
CONFIGURAR LA PUERTA DE ENLACE Y EL DNS PRIMARIO CON LA IP 192.168.0.1
YA DEBERIAS PODER NAVEGAR PERFECTAMENTE.

SERIA MUY BUENO QUE TUS CLIENTES SE CONECTEN A TU RED VIA UNA CONECCION RASS PPPOE COMO SI FUESE QUE CADA UNO TUBIESE UN ADSL.

PARA ESTO DEBERIA TENER QUE HABILITAR EL SERVICIO DE PPPOE , CREAR UN POOL DE IP Y CREAR LOS DISTINTOS PROFILE PARA LA ASIGNACION DE DISTINTAS VELOCIDADES Y POR ULTIMO EL SECRET PARA EL USUARIO Y LA CONTRASEÑA QUE SE LE ASIGNARA A CADA USUARIO PARA PODER CONECTARSE A LA RED Y NAVEGAR.