Mikrotik en un sistema operativo de router que puede ser instalado en una PC o comprar directamente un routerboad con el ROS instalado. El software esta en permanente actualización por lo que a partir de la versión 3.2 realizar un balanceo de carga entre dos o más conexiones a internet es mas sencillo con la opción PC
PCC (Per Connection Classifier) es el método por el cual se divide en porcentajes las conexiones de los usuarios al router asignando el mismo a las distintas conexiones wan disponibles. Asi, al tener dos conexiones a internet irá el 50% a cada una.
en la siguiente guía vamos a balancear dos conexiones de 2MB y 6Mb respectivamente por lo que para que el equilibrio sea más equitativo a la de mayor ancho de banda le asignaremos un 66% de las conexiones y a la otra el restante 33%.
Para el efecto consideramos que el router esta en producción por lo que en esta guía no se desarrolla la configuración inicial.
Balancear las conexiones de internet disponibles consta de cuatro procedimientos:
Configurar los gateway
Marcar el trafico
Asignar porcentajes a las conexiones (PCC)
Enrutar las conexiones
ingresamos nuestros gateway:
/ip route
add gateway=pppoe-out1 distance=1
add gateway=192.168.1.1 check-gateway=ping distance=2
Marcamos el tráfico para que todo lo que entra por una WAN salga por esa misma WAN:
/ip firewall mangle
add chain=prerouting in-interface=pppoe-out1 connection-state=new new-connection-mark=pppoe-out1_conn action=mark-connection passthrough=yes
add chain=prerouting in-interface=eth1-Arnet connection-state=new new-connection-mark=eth1_conn action=mark-connection passthrough=yes
add chain=output connection-mark=pppoe-out1_conn new-routing-mark=to_pppoe-out1 action=mark-routing passthrough=yes
add chain=output connection-mark=eth1_conn new-routing-mark=to_eth1-Arnet action=mark-routing passthrough=yes
Configuramos PCC, como dijimos 2/3 para una y el resto para la otra:
primero marcamos las conexiones:
/ip firewall mangle
add chain=prerouting in-interface=eth3-LAN connection-state=new dst-address-type=!local per-connection-classifier=both-addresses:3/0 action=mark-connection new-connection-mark=pppoe-out1_conn passthrough=yes
add chain=prerouting in-interface=eth3-LAN connection-state=new dst-address-type=!local per-connection-classifier=both-addresses:3/1 action=mark-connection new-connection-mark=eth1_conn passthrough=yes
add chain=prerouting in-interface=eth3-LAN connection-state=new dst-address-type=!local per-connection-classifier=both-addresses:3/2 action=mark-connection new-connection-mark=eth1_conn passthrough=yes
Luego marcamos las rutas:
/ip firewall mangle
add chain=prerouting in-interface=eth3-LAN connection-mark=pppoe-out1_conn action=mark-routing new-routing-mark=to_pppoe-out1 passthrough=yes
add chain=prerouting in-interface=eth3-LAN connection-mark=eth1_conn action=mark-routing new-routing-mark=to_eth1-Arnet passthrough=yes
Finalmente utilizamos esas marcas de ruta para enviarlas a cada conexion:
/ip route
add gateway=pppoe-out1 routing-mark=to_pppoe-out1
add gateway=192.168.1.1 routing-mark=to_eth1-Arnet check-gateway=ping
Observamos las marcas de conexiones y rutas en el mangle del firewall y el balanceo que se produce en connections:
Finalmente vamos a diseñar un nuevo queue tree para que actue con nuestro balanceo de carga:
marcamos los paquetes:
A diferencia de los QoS que comentamos en otros post, aqui solo marcaremos los paquetes, sin considerar las conexiones
/ip firewall mangle
add action=mark-packet chain=prerouting comment="Lista de Archivos" disabled=\
no in-interface=!eth3-LAN new-packet-mark=download-packet passthrough=no \
protocol=tcp src-address-list=download
add action=mark-packet chain=prerouting comment="ICMP (ping)" disabled=no \
new-packet-mark=interactivo passthrough=no protocol=icmp
add action=mark-packet chain=prerouting comment=DNS disabled=no \
new-packet-mark=interactivo passthrough=no protocol=tcp src-port=53
add action=mark-packet chain=postrouting disabled=no dst-port=53 \
new-packet-mark=dns_out passthrough=no protocol=tcp
add action=mark-packet chain=prerouting disabled=no new-packet-mark=\
interactivo passthrough=no protocol=udp src-port=53
add action=mark-packet chain=postrouting disabled=no dst-port=53 \
new-packet-mark=dns_out_udp passthrough=no protocol=udp
add action=mark-packet chain=prerouting comment="http Conexion" \
connection-bytes=0-500000 disabled=no new-packet-mark=http_in \
passthrough=no protocol=tcp src-port=80
add action=mark-packet chain=postrouting connection-bytes=0-500000 disabled=\
no dst-port=80 new-packet-mark=http_out passthrough=no protocol=tcp
add action=mark-packet chain=prerouting comment="http Descargas" \
connection-bytes=500000-2000000 disabled=no new-packet-mark=http_dwn \
passthrough=no protocol=tcp src-port=80
add action=mark-packet chain=prerouting comment="https conexion" \
connection-bytes=0-500000 disabled=no new-packet-mark=https_in \
passthrough=no protocol=tcp src-port=443
add action=mark-packet chain=postrouting connection-bytes=0-500000 disabled=\
no dst-port=443 new-packet-mark=https_out passthrough=no protocol=tcp
add action=mark-packet chain=prerouting comment="https Descargas" \
connection-bytes=500000-2000000 disabled=no new-packet-mark=https_dwn \
passthrough=no protocol=tcp src-port=443
add action=mark-packet chain=prerouting comment="Otras conexiones" disabled=\
no new-packet-mark=Otras_in passthrough=no
add action=mark-packet chain=postrouting disabled=no new-packet-mark=\
Otras_out passthrough=no
add action=mark-packet chain=prerouting comment="SIP and RTP" disabled=no \
dscp=46 new-packet-mark=interactivo passthrough=no
add action=mark-packet chain=prerouting comment="SIP and RTP control" \
disabled=no dscp=26 new-packet-mark=interactivo passthrough=no
add action=mark-packet chain=prerouting comment=ospf disabled=no dscp=48 \
new-packet-mark=interactivo passthrough=no protocol=ospf
Finalmente configuramos el Queue Tree:
con un parent max limit de 80% en Download_all y Upload_all
/queue tree
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=1768k name=Download-All packet-mark="" parent=global-in \
priority=1
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=400k name=Upload-All packet-mark="" parent=global-out priority=\
1
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=yes limit-at=0 \
max-limit=0 name=Descargas packet-mark=download-packet parent=global-in \
priority=8 queue=PCQ_download
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=0 name=descargas packet-mark=download-packet parent=\
Download-All priority=8 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=0 name=www-descargas packet-mark=http_dwn parent=Download-All \
priority=6 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=0 name=www-conexion packet-mark=http_in parent=Download-All \
priority=4 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=0 name=https-conexion packet-mark=https_in parent=Download-All \
priority=3 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=0 name=https-descargas packet-mark=https_dwn parent=\
Download-All priority=6 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=0 name=otras packet-mark=Otras_in parent=Download-All priority=\
7 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=0 name="icmp (ping) Up" packet-mark=icmp parent=Upload-All \
priority=1 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=0 name=dns-Up packet-mark=dns_out parent=Upload-All priority=2 \
queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=0 name=dns_udp-Up packet-mark=dns_out_udp parent=Upload-All \
priority=2 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=0 name=www-conexion-Up packet-mark=http_out parent=Upload-All \
priority=4 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=0 name=https-Up packet-mark=https_out parent=Upload-All \
priority=4 queue=default
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=yes limit-at=0 \
max-limit=0 name=otras-up packet-mark=Otras_out parent=Upload-All \
priority=7 queue=PCQ_upload
add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \
max-limit=0 name=Interactivos packet-mark=interactivo parent=Download-All \
priority=1 queue=default
Vemos cómo quedaron el mangle del firewall y el queue tree:
Fuentes:
http://forum.mikrotik.com/