# by RouterOS 6.48.1
#
#
#
# ether1 รับเน็ตเร้าเตอร์ isp gateway=192.168.1.1
# ether2 รับเน็ตเร้าเตอร์ isp gateway=192.168.2.1
# ether3-5 แจกวง ip 192.168.77.xx
#
/interface bridge
add name=br-local
/interface bridge port
add bridge=br-local interface=ether4
add bridge=br-local interface=ether3
add bridge=br-local interface=ether5
/ip address
add address=192.168.77.1/24 interface=br-local network=192.168.77.0
/ip pool
add name=dhcp_pool1 ranges=192.168.77.2-192.168.77.254
/ip dhcp-server
add address-pool=dhcp_pool1 disabled=no interface=br-local name=dhcp1
/ip dhcp-server network
add address=192.168.77.0/24 dns-server=8.8.8.8 gateway=192.168.77.1
/ip address
add address=192.168.1.254/24 network=192.168.1.0 broadcast=192.168.1.255 interface=ether1
add address=192.168.2.254/24 network=192.168.2.0 broadcast=192.168.2.255 interface=ether2
/ip dns
set allow-remote-requests=yes servers=8.8.8.8
/ip firewall mangle
add action=accept chain=prerouting in-interface=ether1
add action=accept chain=prerouting in-interface=ether2
add action=mark-connection chain=prerouting connection-mark=no-mark \
in-interface=ether1 new-connection-mark=ISP1_conn passthrough=yes
add action=mark-connection chain=prerouting connection-mark=no-mark \
in-interface=ether2 new-connection-mark=ISP2_conn passthrough=yes
add action=mark-connection chain=prerouting dst-address-type=!local \
in-interface=br-local new-connection-mark=ISP1_conn passthrough=yes \
per-connection-classifier=both-addresses-and-ports:2/0
add action=mark-connection chain=prerouting dst-address-type=!local \
in-interface=br-local new-connection-mark=ISP2_conn passthrough=yes \
per-connection-classifier=both-addresses-and-ports:2/1
add action=mark-routing chain=prerouting connection-mark=ISP1_conn \
in-interface=br-local new-routing-mark=to_ISP1 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=ISP2_conn \
in-interface=br-local new-routing-mark=to_ISP2 passthrough=yes
add action=mark-routing chain=output connection-mark=ISP1_conn \
new-routing-mark=to_ISP1 passthrough=yes
add action=mark-routing chain=output connection-mark=ISP2_conn \
new-routing-mark=to_ISP2
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1 src-address=\
192.168.77.0/24
add action=masquerade chain=srcnat out-interface=ether2 src-address=\
192.168.77.0/24
/ip route
add check-gateway=ping distance=1 gateway=192.168.1.1 routing-mark=to_ISP1
add check-gateway=ping distance=1 gateway=192.168.2.1 routing-mark=to_ISP2
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.2.1 distance=2 check-gateway=ping
/system clock
set time-zone-name=Asia/Bangkok