# jun/23/2022 09:50:18 by RouterOS 6.47.9 # software id = Q5HU-07FF # # model = RB941-2nD # serial number = E7FE0E08AD53 /interface bridge add name=bridge1-LAN /interface wireless set [ find default-name=wlan1 ] ssid=MikroTik /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-pppoE set [ find default-name=ether4 ] name=ether4-lan /interface wireless security-profiles set [ find default=yes ] supplicant-identity=MikroTik /ip pool add name=dhcp_pool0 ranges=192.168.14.2-192.168.14.254 add name=dhcp_pool1 ranges=192.168.14.2-192.168.14.254 add name=dhcp_pool2 ranges=192.168.14.2-192.168.14.254 /ip dhcp-server add address-pool=dhcp_pool2 disabled=no interface=bridge1-LAN name=dhcp1 /interface bridge port add bridge=bridge1-LAN interface=ether4-lan add bridge=bridge1-LAN interface=ether3-pppoE /ip address add address=192.168.14.1/24 interface=ether4-lan network=192.168.14.0 /ip dhcp-client add add-default-route=no disabled=no interface=ether1-wan1 script="{\r\ \n :local rmark \"to_wan1\"\r\ \n :local count [/ip route print count-only where comment=\"to_wan1\"]\ \r\ \n :if (\$bound=1) do={\r\ \n :if (\$count = 0) do={\r\ \n /ip route add distance=1 gateway=\$\"gateway-address\" check\ -gateway=ping routing-mark=to_wan1 comment=\"to_wan1\"\r\ \n /ip route add distance=1 gateway=\$\"gateway-address\" check\ -gateway=ping comment=\"to_wan1\"\r\ \n } else={\r\ \n :if (\$count = 1) do={\r\ \n :local test [/ip route find where comment=\"to_wan1\"]\r\ \n :if ([/ip route get \$test gateway] != \$\"gateway-addre\ ss\") do={\r\ \n /ip route set \$test gateway=\$\"gateway-address\"\r\ \n }\r\ \n } else={\r\ \n :error \"Multiple routes found\"\r\ \n }\r\ \n }\r\ \n } else={\r\ \n /ip route remove [find comment=\"to_wan1\"]\r\ \n }\r\ \n}" add add-default-route=no disabled=no interface=ether2-wan2 script="{\r\ \n :local rmark \"to_wan2\"\r\ \n :local count [/ip route print count-only where comment=\"to_wan2\"]\ \r\ \n :if (\$bound=1) do={\r\ \n :if (\$count = 0) do={\r\ \n /ip route add distance=1 gateway=\$\"gateway-address\" check\ -gateway=ping routing-mark=to_wan1 comment=\"to_wan2\"\r\ \n /ip route add distance=1 gateway=\$\"gateway-address\" check\ -gateway=ping comment=\"to_wan2\"\r\ \n } else={\r\ \n :if (\$count = 1) do={\r\ \n :local test [/ip route find where comment=\"to_wan2\"]\r\ \n :if ([/ip route get \$test gateway] != \$\"gateway-addre\ ss\") do={\r\ \n /ip route set \$test gateway=\$\"gateway-address\"\r\ \n }\r\ \n } else={\r\ \n :error \"Multiple routes found\"\r\ \n }\r\ \n }\r\ \n } else={\r\ \n /ip route remove [find comment=\"to_wan2\"]\r\ \n }\r\ \n}" /ip dhcp-server network add address=192.168.14.0/24 gateway=192.168.14.1 /ip firewall mangle add action=accept chain=prerouting comment="ACCEP RULE" in-interface=\ ether1-wan1 add action=accept chain=prerouting in-interface=ether2-wan2 add action=mark-connection chain=prerouting comment="PCC RULE" \ dst-address-type=!local new-connection-mark=wan1_conn passthrough=yes \ per-connection-classifier=both-addresses-and-ports:2/0 src-address=\ 192.168.14.0/24 add action=mark-connection chain=prerouting dst-address-type=!local \ new-connection-mark=wan2_conn passthrough=yes per-connection-classifier=\ both-addresses-and-ports:2/1 src-address=192.168.14.0/24 add action=mark-routing chain=prerouting comment="MARK ROUTING" \ connection-mark=wan1_conn new-routing-mark=to_wan1 passthrough=yes \ src-address=192.168.14.0/24 add action=mark-routing chain=prerouting connection-mark=wan2_conn \ new-routing-mark=to_wan2 passthrough=yes src-address=192.168.14.0/24 /ip firewall nat add action=masquerade chain=srcnat out-interface=ether1-wan1 src-address=\ 192.168.14.0/24 add action=masquerade chain=srcnat out-interface=ether2-wan2 src-address=\ 192.168.14.0/24 /ip route add check-gateway=ping comment=to_wan1 distance=1 gateway=192.168.1.1 \ routing-mark=to_wan1 add check-gateway=ping comment=to_wan2 distance=1 gateway=192.168.4.1 \ routing-mark=to_wan1 add check-gateway=ping comment=to_wan1 distance=1 gateway=192.168.1.1 add check-gateway=ping comment=to_wan2 distance=1 gateway=192.168.4.1 /system clock set time-zone-name=Asia/Manila