You are on page 1of 5

When we want to make Loadbalancing system usedMikrot ik 2.9.x, we can using the rule fromhere.

But there is little different withMikrot ik 3.x Ok then, let's started, i will use 5connection here. IP Address Configuration / ip address add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=Local comment="" disabled=no / ip address add address=10.111.0.2/30 network=10.111.0.0 broadcast=10.111.0.3 interface=Uplink1 comment="" disabled=no / ip address add address=10.112.0.2/30 network=10.112.0.0 broadcast=10.112.0.3 interface=Uplink2 comment="" disabled=no / ip address add address=10.113.0.2/30 network=10.113.0.0 broadcast=10.113.0.3 interface=Uplink3 comment="" disabled=no / ip address add address=10.114.0.2/30 network=10.114.0.0 broadcast=10.114.0.3 interface=Uplink4 comment="" disabled=no / ip address add address=10.115.0.2/30 network=10.115.0.0 broadcast=10.115.0.3 interface=Uplink5 comment="" disabled=no

Mangle Configuration / ip firewall mangle add chain=prerouting in-interface=Local connection-state=ne w nth=5,1 action=mark-connection new-connection-mark=conn1 passthrough=yes comme nt="" disabled=no / ip firewall mangle add chain=prerouting in-interface=Local connection-mark=con n1 action=mark-routing new-routing-mark=conn1 passthrough=no comment="" disabled =no / ip firewall mangle add chain=prerouting in-interface=Local connection-state=ne w nth=4,1 action=mark-connection new-connection-mark=conn2 passthrough=yes comme nt="" disabled=no / ip firewall mangle add chain=prerouting in-interface=Local connection-mark=con n2 action=mark-routing new-routing-mark=conn2 passthrough=no comment="" disabled =no / ip firewall mangle add chain=prerouting in-interface=Local connection-state=ne w nth=3,1 action=mark-connection new-connection-mark=conn3 passthrough=yes comme nt="" disabled=no / ip firewall mangle add chain=prerouting in-interface=Local connection-mark=con n3 action=mark-routing new-routing-mark=conn3 passthrough=no comment="" disabled =no / ip firewall mangle add chain=prerouting in-interface=Local connection-state=ne w nth=2,1 action=mark-connection new-connection-mark=conn4 passthrough=yes comme nt="" disabled=no / ip firewall mangle add chain=prerouting in-interface=Local connection-mark=con n4 action=mark-routing new-routing-mark=conn4 passthrough=no comment="" disabled =no / ip firewall mangle add chain=prerouting in-interface=Local connection-state=ne w action=mark-connection new-connection-mark=conn5 passthrough=yes comment="" di sabled=no / ip firewall mangle add chain=prerouting in-interface=Local connection-mark=con n5 action=mark-routing new-routing-mark=conn5 passthrough=no comment="" disabled =no

0.3 i nterface=Uplink4 comment="" disabled=no / ip address add address=10.2/30 network=10.0.115.1 comment="" disabled=no scope=255 target-scope=1 scope=255 target-scope=1 scope=255 target-scope=1 scope=255 target-scope=1 scope=255 target-scope=1 scope=255 target-scope=1 action=masquerade out-i action=masquerade out-i action=masquerade out-i action=masquerade out-i action=masquerade out-i Explanation First we give a code snippet and then explain what it actually does.2/30 network=10.0.2/30.0.113.0.3 i nterface=Uplink1 comment="" disabled=no / ip address add address=10.0. 255 interface=Local comment="" disabled=no / ip address add address=10.0.1 routing-mark=conn2 comment="" disabled=no ip route add dst-address=0.0.0.115.0.3 i nterface=Uplink3 comment="" disabled=no / ip address add address=10. 10.3 i nterface=Uplink2 comment="" disabled=no / ip address add address=10.168.114.114.0/0 gateway=10.168.2/30 network=10.113.168.0.0.0 broadcast=192.1 routing-mark=conn1 comment="" disabled=no ip route add dst-address=0.0.113.112. 5 uplinkconnection need 5connection mark and 5 routi ng mark.0.2/30.111.0. The LAN interface has the name "Local" and IP address of 192.115.0.0. For the ip firewall mangle.0.0.112.0/0 gateway=10.1 .0.0.2/24 and 10.113.112.2/30 network=10.0.0.1 routing-mark=conn5 comment="" disabled=no ip route add dst-address=0.0 broadcast=10.1 routing-mark=conn4 comment="" disabled=no ip route add dst-address=0.2/24.0.0 broadcast=10.114.0.115. 10.0.1/24.0.111.3 i nterface=Uplink5 comment="" disabled=no The router has 5 upstream (WAN) interfaces with the addresses of 10.1 routing-mark=conn3 comment="" disabled=no ip route add dst-address=0.115.0.1/24 network=192.0 broadcast=10.0.111.112.0.2/30 network=10.0. IP Address and Mangle / ip address add address=192.0.111.0.0 broadcast=10.111.114.0/0 gateway=10.0 broadcast=10. Mangle 1 : nth : 5.0/0 gateway=10.111.2/30.168.0/0 gateway=10.0.113.0.0.0/0 gateway=10.0.0.0.112.0.0.0.Masquerade Local Network / ip firewall nat add chain=srcnat connection-mark=conn1 nterface=Uplink1 comment="" disabled=no / ip firewall nat add chain=srcnat connection-mark=conn2 nterface=Uplink2 comment="" disabled=no / ip firewall nat add chain=srcnat connection-mark=conn3 nterface=Uplink3 comment="" disabled=no / ip firewall nat add chain=srcnat connection-mark=conn4 nterface=Uplink4 comment="" disabled=no / ip firewall nat add chain=srcnat connection-mark=conn5 nterface=Uplink5 comment="" disabled=no Route / 0 / 0 / 0 / 0 / 0 / 0 ip route add dst-address=0. 10.114.

112.1 scope=255 target-scope=10 routing-mark=odd comment="" disabled=no add dst-address=0.0.1 Mangle 4 : nth : 2.0.0.0.0.2/24 network=10.255 interface=wlan1 comment="" disabled=no / ip firewall mangle add chain=prerouting ininterface=Local connection-state=new nth=1.0.0/0 gateway=10.1.1 scope=255 target-scope=10 comment="" disabled=no .0.0 broadcast=192.0.112.112.1 action=mark-connection new-connection-mark=even passthrough=yes comment="" disabled=no add chain=prerouting in-interface=Local connectionmark=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.1.111.0.2 to-ports=0-65535 comment="" disabled=no add chain=srcnat connection-mark=even action=src-nat toaddresses=10.2/24 network=10.0.112.255 interface=Local comment="" disabled= no add address=10.168.1 scope=255 target-scope=10 routing-mark=even comment="" disabled=no add dst-address=0.0.168.0 broadcast=10.255 interface=wlan2 comment="" disabled=no add address=10.112.0 action=mark-connection new-connec tion-mark=odd passthrough=yes comment="" disabled=no add chain=prerouting in-interface=Local connectionmark=odd action=mark-routing new-routing-mark=odd passthrough=no comment="" disa bled=no add chain=prerouting in-interface=Local connectionstate=new nth=1.111.0.1 Mangle 5 : No nth Here the explanation : Mangle 1 : read all traffic and match 1/5 of traffic Mangle 2 : read 4/5 traffic and match 1/4 of they traffic (1/5 total traffic) Mangle 3 : read 3/4 from 4/5 traffic above (or 3/5 total traffic) and match 1/2 traffic above (1/5 total traffic) Mangle 4 : read 2/3 from 3/5 total traffic (or 2/5 total traffic) and match 1/2 traffic above (1/5 total traffic) Mengle 5 : read the rest of traffic (1/5 total traffic) Thats it.0/0 gateway=10.111.112.0.2 to-ports=0-65535 comment="" disabled=no / ip route add dst-address=0.111.1 Mangle 3 : nth : 3.0.Mangle 2 : nth : 4.0.0.0.0.0. Now you can try your setting Setingan lanjutan Quick Start for Impatient Configuration export from the gateway route / ip address add address=192.1/24 network=192.0/0 gateway=10.0.0 broadcast=10.168.

add chain=prerouting in-interface=Local connectionmark=odd action=mark-routing new-routing-mark=odd passthrough=no comment="" disa bled=no The rule above places the routing mark "odd" on all packets that belong to the " odd" connection and stops processing all other mangle in prerouting chain rules for t hese packets. The LAN interface has the name "Local" and IP address of 192. The code above effectively means that each newconnect ion initiated through the router from the local network will be marked as either "od .0 broadcast=192.112.2/24 network=10.112.112.112.168.1 action=mark-connection new-connection-mark=even passthrough= yes comment="" disabled=no add chain=prerouting in-interface=Local connectionmark=even action=mark-routing new-routing-mark=even passthrough=no comment="" di sabled=no These rules do the same for the remaining half of the traffic as the first two r ules for the first half of the traffic.0 broadcast=10.1.2/24 and 10. and mark it withconnection mark "odd".0.111. Mangle : / ip address add address=192.0.0 action=mark-connection new-connec tion-mark=odd passthrough=yes comment="" disabled=no First we take every second packet that establishes new session (note connectionstate=new).0.111.1. add chain=prerouting in-interface=Local connectionstate=new nth=1.0.111.255 interface=Local comment="" disabled= no add address=10.0.168.2/24.0. Consequently all successive packets belonging to the same session will carry theconnection mark "odd".168.1/24 /ip firewall mangle add chain=prerouting ininterface=Local connection-state=new nth=1.0.255 interface=wlan2 comment="" disabled=no add address=10.0.1/24 network=192.0 broadcast=10.0.Explanation First we give a code snippet and then explain what it actually does.111.255 interface=wlan1 comment="" disabled=no The router has two upstream (WAN) interfaces with the addresses of 10.2/24 network=10. Note that we are passing these packets to the second rule (passthrough=yes) to place a rou ting mark on these packets in addition to theconnection mark.0.0.0.168.

NAT / ip firewall nat add chain=srcnat connection-mark=odd action=src-nat to-address es=10.112.111. whi le traffic marked "even" gets "10.1 scope=255 target-scope=10 \ routing-mark=even comment="" disabled=no add dst-address=0.112. http://www.scribd.111.0/0 gateway=10.0.0.111. Finally.2 to-ports=0-65535 comment="" disabled=no add chain=srcnat connection-mark=even action=src-nat toaddresses=10.0.112.2 translated source a ddress) we use 10.112.com/doc/13101595/Mikrotik-Load-Balancing-5 .1 gateway.0.0/0 gateway=10. In the same manner all traffic marked "even" is route d through the 10.0.0.112.0.111.0.0.0.1 scope=255 target-scope=10 \ routing-mark=odd comment="" disabled=no add dst-address=0. / ip route add dst-address=0.2.112. Routing.1 gateway.0.d" or "even" with both routing andconnection marks.0/0 gateway=10.0.1 scope=255 target-scope=10 \ comment="" disabled=no comment="gateway for the router itself" For all traffic marked "odd" (consequently having 10.0.1 gateway.111.2" source IP address. we have one additional entry specifying that traffic from the router itself (the traffic without any routing marks) should go to 10.0.0.0.0.2 to-ports=0-65535 comment="" disabled=no All traffic marked "odd" is being NATted to source IP address of 10.