Sie sind auf Seite 1von 2

ether1 = ether1-gateway 00:0C:29:DC:3F:62

ether2 = ether2-gateway 00:0C:29:DC:3F:58


ether3 = ether3 00:0C:29:DC:3F:4E

/ip dhcp-client
add add-default-route=no dhcp-options=hostname,clientid disabled=no
interface=ether1-gateway use-peer-dns=no use-peer-ntp=no
add add-default-route=no dhcp-options=hostname,clientid disabled=no
interface=ether2-gateway use-peer-dns=no use-peer-ntp=no

/ip address
add address=192.168.88.1/24 interface=ether3 network=192.168.88.0

/ip firewall nat


add action=masquerade chain=srcnat out-interface=ether1-gateway
add action=masquerade chain=srcnat out-interface=ether2-gateway

/ip firewall mangle


add action=mark-connection chain=prerouting comment="Load Balance" connection-
state=new in-interface=ether1-gateway new-connection-mark=ether1_conn
add action=mark-connection chain=prerouting connection-state=new in-
interface=ether2-gateway new-connection-mark=ether2_conn
add action=mark-routing chain=output connection-mark=ether1_conn new-routing-
mark=to_ether1
add action=mark-routing chain=output connection-mark=ether2_conn new-routing-
mark=to_ether2
add action=mark-connection chain=prerouting connection-state=new dst-address-type=!
local in-interface=ether3 new-connection-mark=ether1_conn per-connection-
classifier=both-ports:2/0
add action=mark-connection chain=prerouting connection-state=new dst-address-type=!
local in-interface=ether3 new-connection-mark=ether2_conn per-connection-
classifier=both-ports:2/1
add action=mark-routing chain=prerouting connection-mark=ether1_conn in-
interface=ether3 new-routing-mark=to_ether1
add action=mark-routing chain=prerouting connection-mark=ether2_conn in-
interface=ether3 new-routing-mark=to_ether2

/ip route
add check-gateway=ping comment="Ether1-Wan routing gateway" distance=1
gateway=192.168.0.1 routing-mark=to_ether1
add check-gateway=ping comment="Ether2-Wan routing gateway" distance=1
gateway=192.168.1.1 routing-mark=to_ether2
add comment=Ether1-Wan distance=1 gateway=192.168.0.1
add comment=Ether2-Wan distance=2 gateway=192.168.1.1

Create New Script with name ChangeGateways and copy below lines.

:global newgw [/ip dhcp-client get [find interface="ether1-gateway" ] 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="ether2-gateway" ] 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
}

Das könnte Ihnen auch gefallen