Balanceo de cargas 3 lineas pcc

Tema en 'Balanceo de Carga (Load Balance)' comenzado por Luis escobar martinez, 22 de Marzo de 2016.

  1. De esta manera es mi balanceo esta completo opinen a ver si se puede hacer algunas mejoras.

    PHP:
    /interface ethernet
    set [ find default-name=ether5 ] name=LAN
    set [ find default-name=ether1 ] name=WAN1
    set [ find default-name=ether2 ] name=WAN2
    set [ find default-name=ether3 ] name=WAN3
    /interface pppoe-client
    add ac-name="" add-default-route=no allow=pap,chap,mschap1,mschap2 \
        dial-on-demand=no disabled=no interface=WAN1 keepalive-timeout=60 \
        max-mru=1480 max-mtu=1480 mrru=1600 name=pppoe-out1 password=speedy \
        profile=default service-name="" use-peer-dns=no user=speedy
    add ac-name="" add-default-route=no allow=pap,chap,mschap1,mschap2 \
        dial-on-demand=no disabled=no interface=WAN2 keepalive-timeout=60 \
        max-mru=1480 max-mtu=1480 mrru=1600 name=pppoe-out2 password=speedy \
        profile=default service-name="" use-peer-dns=yes user=speedy
    add ac-name="" add-default-route=no allow=pap,chap,mschap1,mschap2 \
        dial-on-demand=no disabled=no interface=WAN3 keepalive-timeout=60 \
        max-mru=1480 max-mtu=1480 mrru=1600 name=pppoe-out3 password=speedy \
        profile=default service-name="" use-peer-dns=no user=speedy
    /ip dns
    set servers=200.48.225.130,200.48.225.146
    /ip address
    add address=192.168.100.1/24 interface=LAN network=192.168.100.0
    add address=192.168.30.2/24 interface=WAN1 network=192.168.30.0
    add address=192.168.31.2/24 interface=WAN2 network=192.168.31.0
    add address=192.168.32.2/24 interface=WAN3 network=192.168.32.0
    /ip firewall filter
    add action=drop chain=input comment="BLOQUEA SCAN VIA WINBOX" dst-port=5678 \
        protocol=udp
    add action=drop chain=input comment="Bloqueo Ataques DNS" dst-port=53 \
        in-interface=all-ppp protocol=udp
    /ip firewall nat
    add action=masquerade chain=srcnat out-interface=pppoe-out1
    add action=masquerade chain=srcnat out-interface=pppoe-out2
    add action=masquerade chain=srcnat out-interface=pppoe-out3
    /ip firewall address-list
    add address=192.168.100.0/24 list=GW01_LAN
    /ip firewall mangle
    add chain=prerouting dst-address-list=GW01_LAN src-address-list=GW01_LAN
    add action=mark-connection chain=forward comment="REGLAS 2" connection-mark=\
        no-mark in-interface=pppoe-out1 new-connection-mark=WAN1_conn
    add action=mark-connection chain=forward connection-mark=no-mark \
        in-interface=pppoe-out2 new-connection-mark=WAN2_conn
    add action=mark-connection chain=forward connection-mark=no-mark \
        in-interface=pppoe-out3 new-connection-mark=WAN3_conn
    add action=mark-connection chain=prerouting comment="REGLAS 3" \
        connection-mark=no-mark in-interface=pppoe-out1 new-connection-mark=\
        WAN1_conn
    add action=mark-connection chain=prerouting connection-mark=no-mark \
        in-interface=pppoe-out2 new-connection-mark=WAN2_conn
    add action=mark-connection chain=prerouting connection-mark=no-mark \
        in-interface=pppoe-out3 new-connection-mark=WAN3_conn
    add action=jump chain=prerouting connection-mark=no-mark in-interface=LAN \
        jump-target=policy_routing
    add action=mark-routing chain=prerouting comment="REGLAS 4" connection-mark=\
        WAN1_conn new-routing-mark=WAN1_traffic src-address-list=GW01_LAN
    add action=mark-routing chain=prerouting connection-mark=WAN2_conn \
        new-routing-mark=WAN2_traffic src-address-list=GW01_LAN
    add action=mark-routing chain=prerouting connection-mark=WAN3_conn \
        new-routing-mark=WAN3_traffic src-address-list=GW01_LAN
    add action=mark-routing chain=output comment="REGLAS 5" connection-mark=\
        WAN1_conn new-routing-mark=WAN1_traffic
    add action=mark-routing chain=output connection-mark=WAN2_conn \
        new-routing-mark=WAN2_traffic
    add action=mark-routing chain=output connection-mark=WAN3_conn \
        new-routing-mark=WAN3_traffic
    add action=mark-connection chain=policy_routing comment="REGLAS 6" \
        dst-address-type=!local new-connection-mark=WAN1_conn \
        per-connection-classifier=both-addresses:3/0
    add action=mark-connection chain=policy_routing connection-state=new \
        dst-address-type=!local new-connection-mark=WAN2_conn \
        per-connection-classifier=both-addresses:3/1
    add action=mark-connection chain=policy_routing connection-state=new \
        dst-address-type=!local new-connection-mark=WAN3_conn \
        per-connection-classifier=both-addresses:3/2
    /ip route
    add check-gateway=arp distance=1 gateway=pppoe-out1 routing-mark=WAN1_traffic
    add check-gateway=arp distance=1 gateway=pppoe-out2 routing-mark=WAN2_traffic
    add check-gateway=arp distance=1 gateway=pppoe-out3 routing-mark=WAN3_traffic
    add check-gateway=arp distance=1 gateway=pppoe-out1
    add check-gateway=arp distance=2 gateway=pppoe-out2
    add check-gateway=arp distance=3 gateway=pppoe-out3
     
    Última modificación por un moderador: 24 de Marzo de 2016
    A Manulu le gusta esto.
  2. Howard Smith

    Howard Smith Member

    A mi parecer se puede añadir dos reglas para que todo lo que sea Banco BCP salga por una linea

    PHP:
    add action=mark-routing chain=prerouting comment="WEB MAIL" dst-port=2095 \
        new-routing-mark=WAN1_traffic passthrough=no protocol=tcp
    add action=mark-routing chain=prerouting comment=BCP dst-address-list=BCP \
        new-routing-mark=WAN1_traffic passthrough=no
    add action=mark-connection chain=prerouting comment="REGLAS 3" connection-mark=\
        no-mark in-interface=pppoe-out1 new-connection-mark=WAN1_conn
    add action=mark-connection chain=prerouting connection-mark=no-mark \
        in-interface=pppoe-out2 new-connection-mark=WAN2_conn
    add action=mark-connection chain=prerouting connection-mark=no-mark \
        in-interface=pppoe-out3 new-connection-mark=WAN3_conn
    add action=mark-routing chain=output comment="REGLAS 5" connection-mark=\
        WAN1_conn new-routing-mark=WAN1_traffic
    add action=mark-routing chain=output connection-mark=WAN2_conn \
        new-routing-mark=WAN2_traffic
    add action=mark-routing chain=output connection-mark=WAN3_conn \
        new-routing-mark=WAN3_traffic
    add action=mark-routing chain=prerouting comment="REGLAS 4" connection-mark=\
        WAN1_conn new-routing-mark=WAN1_traffic src-address-list=GW01_LAN
    add action=mark-routing chain=prerouting connection-mark=WAN2_conn \
        new-routing-mark=WAN2_traffic src-address-list=GW01_LAN
    add action=mark-routing chain=prerouting connection-mark=WAN3_conn \
        new-routing-mark=WAN3_traffic src-address-list=GW01_LAN
    add action=mark-connection chain=policy_routing comment="REGLAS 6" \
        dst-address-type=!local new-connection-mark=WAN1_conn \
        per-connection-classifier=both-addresses:3/0
    add action=mark-connection chain=policy_routing connection-state=new \
        dst-address-type=!local new-connection-mark=WAN2_conn \
        per-connection-classifier=both-addresses:3/1
    add action=mark-connection chain=policy_routing connection-state=new \
        dst-address-type=!local new-connection-mark=WAN3_conn \
        per-connection-classifier=both-addresses:3/2

    [​IMG]
     
    Última modificación por un moderador: 24 de Marzo de 2016
    A Manulu y Luis escobar martinez les gusta esto.
  3. Gracias por el aporte veré cómo anda.
     
    A MikrotikPeru le gusta esto.
  4. Angel Romero

    Angel Romero New Member

    Es para 3 lineas con igual ancho de banda? no soy tan experto en el caso.
     
  5. Esta configuración la uso con 3 líneas 2 de 15mb y una de 10 mb. Y anda muy bien.
     
  6. Howard Smith

    Howard Smith Member

    Listo Compañero , Haber si te preparas una guía de algún tema . Conversar de Ubiquiti también seria ideal.
     
  7. Que es lo que tienes en mente con Ubiquiti? Y con qué equipos?
     
    A Manulu le gusta esto.
  8. DanniGarcia

    DanniGarcia New Member

    buenas tarde amigos tengo 1 problema con el balancer necesito 1 scrip que le haga pin a las wan y la que no responda que le haga release son 10 lineas adsl se le agradece su colaboración
     
  9. MikrotikPeru

    MikrotikPeru Well-Known Member

    Ahi va hermano

    Código (Javascript):
    :local inter ("wan1")
    :local ipPing ("8.8.8.8")
    :global oldGatewayWAN1
    :global totalrun1
    :global infoWAN1
    :global stats1

    :if ([:len [$totalrun1]] = 0) do={
        :set totalrun1 "1"
    } else={
        :set totalrun1 ($totalrun1+1)
    }

    :if ([:len [$stats1]] = 0) do={
        :set stats1 "x"
    } else={
        :set stats1 ("$infoWAN1 / $totalrun1")
    }

    :if ([:len [$oldGatewayWAN1]] < 3) do={
        :set oldGatewayWAN1 "0.0.0.0"
    }
    :log info ("$inter: $inter" . ": PARTE 1")
    /ip dhcp-client enable [find interface=$inter]
    :delay 10s
    :local pingip

    #:local cGateway [/ip dhcp-client get $inter gateway]
    :local cGateway [/ip dhcp-client get number=0 gateway]

    :log info ("$inter: cGateway --> $cGateway")
    /ip route {
        :foreach i in=[find comment=("ping_$inter")] do={
            :log info ("$inter: ping_$inter")
            /ip route remove $i
        }
    }
    /ip route add distance=1 dst-address=$ipPing gateway=("$cGateway%$inter") comment=("ping_$inter")
    :set pingip [/ping $ipPing count=10]
    :log info ("$inter --> begin pinging")
    :if ($pingip = 0) do={
        :set infoWAN1 ($infoWAN1+1)
        :log info ("$inter --> pinging: $pingip")
        /ip dhcp-client disable [find interface=$inter]
        /ip route disable [find comment=$inter]
        /ip firewall mangle disable [find comment=$inter]
    } else={
        /ip route enable [find comment=$inter]
        /ip firewall mangle enable [find comment=$inter]
    }
    :log info ("$inter --> end pinging")
    :log info ("$inter: $inter" . ": PARTE 2")
    :local j
    #:local cGateway [/ip dhcp-client get $inter gateway]
    :local cGateway [/ip dhcp-client get number=0 gateway]

    :local cWlan ($inter . "-" . $cGateway)
    :local fWlan ($inter . "-" . $oldGatewayWAN1)
    :log info ("$inter: Gateway in file: " . $oldGatewayWAN1)
    :log info ("$inter: Actual Gateway: " . $cGateway)
    :log info ("$inter: $cGateway%$inter")
    :if ($oldGatewayWAN1 != $cGateway) do={
        :set oldGatewayWAN1 "0.0.0.0"
        /ip route {
            :foreach i in=[find comment=$inter] do={
                :log info ("$inter: $inter")
                /ip route remove $i
            }
        }
        /ip route add distance=1 dst-address=0.0.0.0/0 gateway=("$cGateway%$inter") routing-mark=("to_$inter") comment=$inter
        /ip route add distance=1 dst-address=0.0.0.0/0 gateway=("$cGateway%$inter") comment=$inter
        :set oldGatewayWAN1 $cGateway
    }
    Saludos,
     
  10. DanniGarcia

    DanniGarcia New Member


    saludos amigo muchas gracias por el aporte de verdad muchas gracias

    ahora solo lo pego oh tengo que hacerle algo mas al scrip de verdad no soy muy experto con mikrotik
     

Comparte esta página