Mikrotik Load Balancing for 2 WAN

Refference : Learning Inventins Laboratory

02Loadbalance_30-3_10-1Mbps

การทดสอบความเร็ว ADSL Thailand  WAN1 = 30/3Mbps , WAN2 = 10/1Mbps

01Loadbalance_30-3_10-1Mbps

การทดสอบความเร็ว CAT Internet Speed Tester  WAN1 = 30/3Mbps , WAN2 = 10/1Mbps

Mikrotik  Command Line Script

Step-1 : Add bridge-local for Local Area Network (LAN)

/interface bridge
add mtu=1528 name=bridge-local

Step-2 : Define Interface name

/interface ethernet
set [ find default-name=ether3 ] name=Local
set [ find default-name=ether1 ] name=ether1-WAN
set [ find default-name=ether2 ] name=ether2-WAN

Step-3 : Add Wireless SSID = “KitDEE-Studio”

/interface wireless
set [ find default-name=wlan1 ] disabled=no ssid=KitDEE-Studio
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa2-psk mode=dynamic-keys \
wpa-pre-shared-key=KitDEE-Studio wpa2-pre-shared-key=1234567890

Step-4 : Add IP Address for WAN1, WAN2 and LAN Interface

/ip address
add address=192.168.2.2/24 interface=ether1-WAN network=192.168.2.0
add address=192.168.99.2/24 interface=ether1-WAN network=192.168.99.0
add address=192.168.199.1/24 interface=Local network=192.168.199.0

 

Step-5 : DHCP Server Setting

/ip dhcp-server network
add address=192.168.199.0/24 dns-server=192.168.199.1 gateway=192.168.199.1

/ip pool
add name=dhcp ranges=192.168.199.10-192.168.199.254
/ip dhcp-server
add address-pool=dhcp disabled=no interface=bridge-local name=default

Step-6 : Add any interface to bridge-local

/interface bridge port
add bridge=bridge-local interface=Local
add bridge=bridge-local interface=wlan1
add bridge=bridge-local interface=ether3
add bridge=bridge-local interface=ether5

Step-7 : DNS IP Setting
/ip dns
set allow-remote-requests=yes cache-size=5000KiB max-udp-packet-size=512 \
servers=61.19.245.245,8.8.8.8

Step-7 : Firewall Load-balance for 2 WAN

/ip firewall mangle
> add action=mark-connection chain=input in-interface=ether1-WAN new-connection-mark=WAN1_conn
> add action=mark-connection chain=input in-interface=ether2-WAN new-connection-mark=WAN2_conn

> add action=mark-connection chain=input in-interface=ether1-WAN new-connection-mark=WAN1_conn
> add action=mark-connection chain=input in-interface=ether2-WAN new-connection-mark=WAN2_conn

> add chain=prerouting dst-address=192.168.2.0/24 in-interface=bridge-local
> add chain=prerouting dst-address=192.168.99.0/24 in-interface=bridge-local

> add action=mark-connection chain=prerouting dst-address-type=!local \
in-interface=bridge-local new-connection-mark=WAN1_conn \
per-connection-classifier=both-addresses-and-ports:2/0

> add action=mark-connection chain=prerouting dst-address-type=!local \
in-interface=bridge-local new-connection-mark=WAN2_conn \
per-connection-classifier=both-addresses-and-ports:2/1

> add action=mark-routing chain=prerouting connection-mark=WAN1_conn \
in-interface=bridge-local new-routing-mark=to_WAN1

> add action=mark-routing chain=prerouting connection-mark=WAN2_conn \
in-interface=bridge-local new-routing-mark=to_WAN2

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

Step-7 : Check WAN gateway by ping

/ip route
add check-gateway=ping distance=1 gateway=192.168.2.1 routing-mark=to_WAN1
add check-gateway=ping distance=1 gateway=192.168.99.1 routing-mark=to_WAN2
add check-gateway=ping distance=1 gateway=192.168.2.1
add check-gateway=ping distance=2 gateway=192.168.99.1

***** Have a good time *****

Advertisements