Friday, 20 May 2016

4 WAN Load Balancing

/ip address
add address=192.168.0.1/24 disabled=no interface=Local network=192.1
add address=192.168.220.5/24 disabled=no interface=ether1 network=\
    192.168.220.0
add address=192.168.221.6/24 disabled=no interface=ether2 network=\
    192.168.221.0
add address=192.168.224.6/24 disabled=no interface=ether3 network=\
    192.168.224.0
add address=192.168.226.6/24 disabled=no interface=ether4 network=\
    192.168.226.0


/ip firewall mangle
add action=mark-connection chain=input disabled=no in-interface=ether1 new-connection-mark=\
    WAN1_conn passthrough=yes
add action=mark-connection chain=input disabled=no in-interface=ether2 new-connection-mark=\
    WAN2_conn passthrough=yes
add action=mark-connection chain=input disabled=no in-interface=ether3 new-connection-mark=\
    WAN3_conn passthrough=yes
add action=mark-connection chain=input disabled=no in-interface=ether4 new-connection-mark=\
    WAN4_conn passthrough=yes
add action=mark-routing chain=output connection-mark=WAN1_conn disabled=no new-routing-mark=\
    to_WAN1 passthrough=yes
add action=mark-routing chain=output connection-mark=WAN2_conn disabled=no new-routing-mark=\
    to_WAN2 passthrough=yes
add action=mark-routing chain=output connection-mark=WAN3_conn disabled=no new-routing-mark=\
    to_WAN3 passthrough=yes
add action=mark-routing chain=output connection-mark=WAN4_conn disabled=no new-routing-mark=\
    to_WAN4 passthrough=yes
add action=accept chain=prerouting disabled=no dst-address=192.168.220.0/24 in-interface=Local
add action=accept chain=prerouting disabled=no dst-address=192.168.221.0/24 in-interface=Local
add action=accept chain=prerouting disabled=no dst-address=192.168.224.0/24 in-interface=Local
add action=accept chain=prerouting disabled=no dst-address=192.168.226.0/24 in-interface=Local
add action=mark-connection chain=prerouting disabled=no dst-address-type=!local in-interface=\
    Local new-connection-mark=WAN1_conn passthrough=yes per-connection-classifier=\
    both-addresses-and-ports:4/0
add action=mark-connection chain=prerouting disabled=no dst-address-type=!local in-interface=\
    Local new-connection-mark=WAN2_conn passthrough=yes per-connection-classifier=\
    both-addresses-and-ports:4/1
add action=mark-connection chain=prerouting disabled=no dst-address-type=!local in-interface=\
    Local new-connection-mark=WAN3_conn passthrough=yes per-connection-classifier=\
    both-addresses-and-ports:4/2
add action=mark-connection chain=prerouting disabled=no dst-address-type=!local in-interface=\
    Local new-connection-mark=WAN4_conn passthrough=yes per-connection-classifier=\
    both-addresses-and-ports:4/3
add action=mark-routing chain=prerouting connection-mark=WAN1_conn disabled=no in-interface=\
    Local new-routing-mark=to_WAN1 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN2_conn disabled=no in-interface=\
    Local new-routing-mark=to_WAN2 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN3_conn disabled=no in-interface=\
    Local new-routing-mark=to_WAN3 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN4_conn disabled=no in-interface=\
    Local new-routing-mark=to_WAN4 passthrough=yes

/ip firewall nat
add action=masquerade chain=srcnat disabled=no out-interface=ether1
add action=masquerade chain=srcnat disabled=no out-interface=ether2
add action=masquerade chain=srcnat disabled=no out-interface=ether3
add action=masquerade chain=srcnat disabled=no out-interface=ether4

/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    192.168.220.1 routing-mark=to_WAN1 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    192.168.221.1 routing-mark=to_WAN2 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    192.168.224.1 routing-mark=to_WAN3 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    192.168.226.1 routing-mark=to_WAN4 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    192.168.220.1 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=2 dst-address=0.0.0.0/0 gateway=\
    192.168.221.1 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=3 dst-address=0.0.0.0/0 gateway=\
    192.168.224.1 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=4 dst-address=0.0.0.0/0 gateway=\
    192.168.226.1 scope=30 target-scope=10

No comments:

Post a Comment