Mikrotik Router: Load Balancing 2WAN
1. Comment Interface
/interface ethernet
set [ find default-name=ether1 ] name=ether1-WAN1
set [ find default-name=ether2 ] name=ether2-WAN2
set [ find default-name=ether3 ] name=ether3-LAN
2. Setting Up IP Address (WAN and LAN)
/ip address
add address=96.9.76.2/25 interface=ether1-WAN1 network=96.9.76.0
add address=203.217.170.30/24 interface=ether2-WAN2 network=203.217.170.0
add address=192.168.1.1/24 interface=ether3-LAN network=192.168.1.0
3. Setting Up DNS Server
/ip dns
set servers=203.217.168.27,203.217.168.36
4. Setting Up DHCP Server
/ip dhcp-server network
add address=192.168.1.0/24 gateway=192.168.1.1
/ip pool
add name=dhcp_pool1 ranges=192.168.1.2-192.168.1.254
/ip dhcp-server
add address-pool=dhcp_pool1 disabled=no interface=ether3-LAN name=dhcp1
5. Setting Up Mangle
/ip firewall mangle
add action=mark-connection chain=input in-interface=ether1-WAN1 log-prefix="" new-connection-mark=WAN1_CONN passthrough=no
add action=mark-connection chain=input in-interface=ether2-WAN2 log-prefix="" new-connection-mark=WAN2_CONN passthrough=no
add action=mark-routing chain=output connection-mark=WAN1_CONN log-prefix="" new-routing-mark=na_WAN1 passthrough=no
add action=mark-routing chain=output connection-mark=WAN2_CONN log-prefix="" new-routing-mark=na_WAN2 passthrough=no
add action=accept chain=prerouting dst-address=96.9.76.0/25 in-interface=ether3-LAN log-prefix=""
add action=accept chain=prerouting dst-address=203.217.170.0/24 in-interface=ether3-LAN log-prefix=""
add action=mark-connection chain=prerouting dst-address-type=!local in-interface=ether3-LAN log-prefix="" new-connection-mark=WAN1_CONN passthrough=yes per-connection-classifier=both-addresses-and-ports:2/0
add action=mark-connection chain=prerouting dst-address-type=!local in-interface=ether3-LAN log-prefix="" new-connection-mark=WAN2_CONN passthrough=yes per-connection-classifier=both-addresses-and-ports:2/1
add action=mark-routing chain=prerouting connection-mark=WAN1_CONN in-interface=ether3-LAN log-prefix="" new-routing-mark=na_WAN1 passthrough=no
add action=mark-routing chain=prerouting connection-mark=WAN2_CONN in-interface=ether3-LAN log-prefix="" new-routing-mark=na_WAN2 passthrough=no
6. Setting Up Route
/ip route
add check-gateway=ping distance=1 gateway=96.9.76.1 routing-mark=na_WAN1
add check-gateway=ping distance=1 gateway=203.217.170.1 routing-mark=na_WAN2
add check-gateway=ping distance=1 gateway=96.9.76.1
add check-gateway=ping distance=2 gateway=203.217.170.1
7. Setting Up NAT
/ip firewall nat
add action=masquerade chain=srcnat log-prefix="" out-interface=ether1-WAN1
add action=masquerade chain=srcnat log-prefix="" out-interface=ether2-WAN2
Test Result:
No comments:
Post a Comment