ether1 = ISP1
ether2 = ISP2
ether3 = bridge
Step 0.
Macs if need
set [ find default-name=ether1 ] mac-address=x name=ISP1
set [ find default-name=ether2 ] mac-address=x name=ISP2
Step 1.
Add dynamic client on ether1 & ether2 (WAN1 & WAN2)
/ip dhcp-client add add-default-route=no dhcp-options=hostname,clientid disabled=no interface=ISP1 use-peer-dns=no use-peer-ntp=no add add-default-route=no dhcp-options=hostname,clientid disabled=no interface=ISP2 use-peer-dns=no use-peer-ntp=no |
Step 2: Add Lan Interface IP . ( ether3 )
1
2
|
/ip address add address=192.168.88.1/24 interface=ether3 network=192.168.88.0 |
Step 3: Add Firewall Nat rule.
/ip firewall nat add action=masquerade chain=srcnat disabled=yes out-interface=ISP1
add action=masquerade chain=srcnat disabled=yes out-interface=ISP2
|
Step 4: Add firewall Mangle Rules
/ip firewall mangle add action=mark-connection chain=prerouting comment=ISP1 connection-state=new disabled=yes in-interface=ISP1 new-connection-mark=ISP1-conn passthrough=yes
add action=mark-routing chain=output comment=ISP1 connection-mark=ISP1-conn disabled=yes new-routing-mark=ISP1-route passthrough=yes add action=mark-connection chain=prerouting comment=ISP2 connection-state=new disabled=yes in-interface=ISP2 new-connection-mark=ISP2-conn passthrough=yes add action=mark-routing chain=output comment=ISP2 connection-mark=ISP2-conn disabled=yes new-routing-mark=ISP2-route passthrough=yes add action=mark-connection chain=prerouting comment=ISP1 connection-state=new disabled=yes dst-address-type=!local in-interface=bridge new-connection-mark=ISP1-conn passthrough=yes per-connection-classifier=both-addresses:2/0 add action=mark-connection chain=prerouting comment=ISP2 connection-state=new disabled=yes dst-address-type=!local in-interface=bridge new-connection-mark=ISP2-conn passthrough=yes per-connection-classifier=both-addresses:2/1 add action=mark-routing chain=prerouting comment=ISP1 connection-mark=ISP1-conn disabled=yes in-interface=bridge new-routing-mark=ISP1-route passthrough=yes add action=mark-routing chain=prerouting comment=ISP2 connection-mark=ISP2-conn disabled=yes in-interface=bridge new-routing-mark=ISP2-route passthrough=yes add action=mark-connection chain=input disabled=yes in-interface=ISP1 new-connection-mark=ISP1-conn passthrough=yes add action=mark-routing chain=output connection-mark=ISP1-conn disabled=yes new-routing-mark=ISP1-route passthrough=no add action=mark-connection chain=input disabled=yes in-interface=ISP2 new-connection-mark=ISP2-conn passthrough=yes add action=mark-routing chain=output connection-mark=ISP2-conn disabled=yes new-routing-mark=ISP2-route passthrough=no add action=mark-connection chain=forward disabled=yes in-interface=ISP1 new-connection-mark=ISP1-conn-f passthrough=no add action=mark-routing chain=prerouting connection-mark=ISP1-conn-f disabled=yes in-interface=bridge new-routing-mark=ISP1-route add action=mark-connection chain=forward disabled=yes in-interface=ISP2 new-connection-mark=ISP2-conn-f passthrough=no add action=mark-routing chain=prerouting connection-mark=ISP2-conn-f disabled=yes in-interface=bridge new-routing-mark=ISP2-route
|
Step 5: Add Routes ( Setting temporary gateway)
/ip route add check-gateway=ping comment="Ether1-Wan routing gateway" distance=1 gateway=192.168.0.1 routing-mark=ISP1-route add check-gateway=ping comment="Ether2-Wan routing gateway" distance=1 gateway=192.168.1.1 routing-mark=ISP2-route add comment=Ether1-Wan distance=1 gateway=192.168.0.1 add comment=Ether2-Wan distance=2 gateway=192.168.1.1 |
step 6: Create New Script with name change_gw and copy below lines.
:global newgw [/ip dhcp-client get [find interface="ISP1" ] gateway ]
:global activegw [/ip route get [/ip route find comment="Ether1-Wan"] gateway ] :if ($newgw != $activegw) do={ /ip route set [find comment="Ether1-Wan"] gateway=$newgw /ip route set [find comment="Ether1-Wan routing gateway"] gateway=$newgw } :global newgw [/ip dhcp-client get [find interface="ISP2" ] gateway ] :global activegw [/ip route get [/ip route find comment="Ether2-Wan"] gateway ] :if ($newgw != $activegw) do={ /ip route set [find comment="Ether2-Wan"] gateway=$newgw /ip route set [find comment="Ether2-Wan routing gateway"] gateway=$newgw } |
Step 7: Final Step.