9
Balanceig de càrrega amb Mikrotik Aquest document ha estat creat per Jordi Clopés Esteban i està protegit per la llicencia Creative Commons by-sa 3.0 Twitter @jordiclopes [email protected]

Balanceig de càrrega amb Mikrotik

Embed Size (px)

Citation preview

Page 1: Balanceig de càrrega amb Mikrotik

Balanceig de càrrega amb Mikrotik

Aquest document ha estat creat per Jordi Clopés Estebani està protegit per la llicencia Creative Commons by-sa 3.0Twitter @[email protected]

Page 2: Balanceig de càrrega amb Mikrotik

QUÈ ÉS EL BALANCEIG DE CÀRREGA?

Donades dos o més sortides a Internet podem repartir la càrrega de les connexions a Internet entre ambdues sortides a Internet, repartint-ho de forma equitativa i aprofitant les dues connexions.

Page 3: Balanceig de càrrega amb Mikrotik

ESQUEMA

Page 4: Balanceig de càrrega amb Mikrotik

BALANCEIG PER PROTOCOL

Podem triar la sortida a Internet d'una connexió en funció del protocol que utilitza. Per exemple, podem escollir que el tràfic HTTP surti per l'ADSL 1 i el tràfic P2P per l'ADSL 2.

Page 5: Balanceig de càrrega amb Mikrotik

BALANCEIG PER PROTOCOL

#Definim l'adreçament#ether1 serà la interfície que connecta amb la nostra LAN (192.168.1.0/24)#ether2 connecta amb el primer ADSL (192.168.10.1)#ether3 connecta amb el segon ADSL (192.168.20.1)

/ip addressadd address=192.168.1.1/24 disabled=no interface=ether1 network=192.168.1.0add address=192.168.10.2/24 disabled=no interface=ether2 network=192.168.10.0add address=192.168.20.2/24 disabled=no interface=ether3 network=192.168.20.0

Page 6: Balanceig de càrrega amb Mikrotik

BALANCEIG PER PROTOCOL#Emmascarem tot el que surti cap a Internet per ether2 i ether3

/ip firewall natadd chain=srcnat action=masquerade out-interface="ether2" comment="Gateway 192.168.10.0/24" disabled=noadd chain=srcnat action=masquerade out-interface="ether3" comment="Gateway 192.168.20.0/24" disabled=no

Page 7: Balanceig de càrrega amb Mikrotik

BALANCEIG PER PROTOCOL

#Marquem el tràfic HTTP, SSL, P2P i la resta de tràfic

/ip firewall mangle

add chain=prerouting action=mark-routing new-routing-mark="HTTP Trafico" passthrough=no dst-port=80 protocol=tcp comment="" disabled=no src-address=192.168.1.0/24

add chain=prerouting action=mark-routing new-routing-mark="SSL Trafico" passthrough=no dst-port=443 protocol=tcp comment="" disabled=no src-address=192.168.1.0/24

add chain=prerouting action=mark-routing new-routing-mark="P2P Trafico" passthrough=no p2p=all-p2p comment="" disabled=no src-address=192.168.1.0/24

add chain=prerouting action=mark-routing new-routing-mark="Unknown Trafico" passthrough=no comment="" disabled=no src-address=192.168.1.0/24

Page 8: Balanceig de càrrega amb Mikrotik

BALANCEIG PER PROTOCOL

#Enrutem el tràfic cap a els ADSLs en funció de les marques (MANGLE) que hem fet #prèviament.

/ip routeadd dst-address=0.0.0.0/0 gateway=192.168.20.1 scope=255 target-scope=10 routing-mark="HTTP Trafico" comment="" disabled=no

add dst-address=0.0.0.0/0 gateway=192.168.20.1 scope=255 target-scope=10 routing-mark="SSL Trafico" comment="" disabled=no

add dst-address=0.0.0.0/0 gateway=192.168.10.1 scope=255 target-scope=10 routing-mark="P2P Trafico" comment="" disabled=no

add dst-address=0.0.0.0/0 gateway=192.168.10.1 scope=255 target-scope=10 routing-mark="Unknown Trafico" comment="" disabled=no

Page 9: Balanceig de càrrega amb Mikrotik

COMPROVACIÓ

Generem el tràfic pertinent i observem per quina interfície (ether2 o ether 3) és enrutat cap a Internet.