Community discussions

MikroTik App
just joined
Topic Author
Posts: 1
Joined: Thu Sep 30, 2021 10:07 pm

Help with load balancing script

Thu Sep 30, 2021 10:28 pm

Hi Team I'm having an issue whit my script and I think that have something wrong on the routes... My scenario is two internet providers with same speed (100Mbps), and routers in bridge mode (so public ip is going to change from time to time) what I need to do is adding both bandwidth and have failover.

/ip dhcp-client
add interface=ether1 disabled=no comment=Telecentro
add interface=ether2 disabled=no comment=Fibertel

/interface bridge
add name=bridge1

/interface bridge port
add bridge=bridge1 interface=ether3
add bridge=bridge1 interface=ether4
add bridge=bridge1 interface=ether5

/ip address
add address= comment=Lan interface=bridge1 network=

/ip dhcp-server network
add address= comment=defconf gateway= dns-server=

/ip pool
add name=default-dhcp ranges=

/ip dhcp-server
add address-pool=default-dhcp disabled=no interface=bridge name=defconf

/ip dns
set allow-remote-requests=yes
set servers=

/ip firewall
nat add action=masquerade chain=srcnat comment="WAN 1" out-interface=ether1
nat add action=masquerade chain=srcnat comment="WAN 2" out-interface=ether2

/ip route
add check-gateway=ping comment="Ruteo wan 1" distance=1 gateway=ether1 \ routing-mark=to_ether1
add check-gateway=ping comment="Ruteo wan 2" distance=1 gateway=ether2 \ routing-mark=to_ether2
add check-gateway=ping comment="Wan 1" distance=1 gateway=ether1
add check-gateway=ping comment="Wan 2" distance=2 gateway=ether2

/ip firewall mangle
add action=mark-connection chain=prerouting comment="Marca de conexiones" \ in-interface=ether1 new-connection-mark=ether1_conn
add action=mark-connection chain=prerouting in-interface=ether2 \ new-connection-mark=ether2_conn
add action=mark-routing chain=output comment=Salida connection-mark=ether1_conn \ new-routing-mark=to_ether1
add action=mark-routing chain=output connection-mark=ether2_conn \ new-routing-mark=to_ether2
add action=mark-connection chain=prerouting comment="Telecentro" \ connection-mark=no-mark dst-address-type=!local in-interface=bridge1 \ new-connection-mark=ether1_conn per-connection-classifier=\ both-addresses:4/0
add action=mark-connection chain=prerouting comment="Fibertel" \ connection-mark=no-mark dst-address-type=!local in-interface=bridge1 \ new-connection-mark=ether2_conn per-connection-classifier=\ both-addresses:4/1
add action=mark-connection chain=prerouting connection-mark=no-mark \ dst-address-type=!local in-interface=bridge1 new-connection-mark=ether2_conn \ per-connection-classifier=both-addresses:4/2
add action=mark-connection chain=prerouting connection-mark=no-mark \ dst-address-type=!local in-interface=bridge1 new-connection-mark=ether2_conn \ per-connection-classifier=both-addresses:4/3
add action=mark-routing chain=prerouting connection-mark=ether1_conn \ in-interface=bridge1 new-routing-mark=to_ether1
add action=mark-routing chain=prerouting connection-mark=ether2_conn \ in-interface=bridge1 new-routing-mark=to_ether2

Can someone help me?

Who is online

Users browsing this forum: No registered users and 3 guests