HomeTech HomeTech Author
Title: MikroTik - Two WAN load balance | Line Merger PCC method with Hotspot
Author: HomeTech
Rating 5 of 5 Des:
MikroTik is a powerful Router and has lots of features and services. In this tutorial we will learn how to use multiple WAN connection and l...
MikroTik is a powerful Router and has lots of features and services. In this tutorial we will learn how to use multiple WAN connection and load balance the traffic between these WAN connections. I am using two ADSL connection and change the IP address as below.

ADSL Router 1 IP : 192.168.1.1
ADSL Router 2 IP : 192.168.10.1

and MikroTik Ethernet Ports IP are
Local : 192.168.0.1
WAN1 : 192.168.1.20
WAN2 : 192.168.10.20

Script

/ip address
add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=Local
add address=192.168.1.20/24 network=192.168.1.0 broadcast=192.168.1.255 interface=WAN1
add address=192.168.10.20/24 network=192.168.10.0 broadcast=192.168.10.255 interface=WAN2

/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=8.8.8.8

/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn

add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2

add chain=prerouting dst-address=192.168.1.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.10.0/24 action=accept in-interface=Local

add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection new-connection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection new-connection-mark=WAN2_conn passthrough=yes

add chain=prerouting connection-mark=WAN1_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN1
add chain=prerouting connection-mark=WAN2_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN2

/ip route
add dst-address=0.0.0.0/0 gateway=192.168.1.1 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.10.1 routing-mark=to_WAN2 check-gateway=ping

add dst-address=0.0.0.0/0 gateway=192.168.1.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.10.1 distance=2 check-gateway=ping

/ip firewall nat
add chain=srcnat out-interface=WAN1 action=masquerade
add chain=srcnat out-interface=WAN2 action=masquerade

For uneven WAN connections for example WAN,1 is of 4MB and WAN,2 is of 8 Mb
------------------------------------------------------------------------------------------------------
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection new-connection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection new-connection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/2 action=mark-connection new-connection-mark=WAN2_conn passthrough=yes


PCC with Hotspot
----------------------
/ip firewall nat add action=accept chain=pre-hotspot disabled=no dst-address-type=!local hotspot=auth

You can adjust the script according to your IP scheme or make use these IP

Download the Two WAN load Balance Script

This script is for equal bandwidth connection and also unequal just read it carefully and execute command as per your scenario and requirement. Don't just blindly copy and paste the script.

Thanks for reading and watching.
Visit my YouTube Channel HomeTech

Please Support my YouTube Channel by liking and subscribing
I spend more time on my YouTube Channel so all comments are 101%  replied there
Comments and suggestions are welcome to improve the tutorial and help other

Share Happiness

See the video for more details
Comming Soon

Advertisement

Post a Comment

 
Top