59. Mikrotik Auto Load Balancing with 5 Internet Connectios(1 Gateway)

Here is a Script:

/ip address
add address=192.168.92.2/24 interface=ether6 network=192.168.92.0

/ip firewall mangle
add action=mark-connection chain=prerouting connection-state=new \
    in-interface=ether6 new-connection-mark=conn1 nth=5,1
add action=mark-routing chain=prerouting connection-mark=conn1 in-interface=\
    ether6 new-routing-mark=conn1 passthrough=no
add action=mark-connection chain=prerouting connection-state=new \
    in-interface=ether6 new-connection-mark=conn2 nth=5,2
add action=mark-routing chain=prerouting connection-mark=conn2 in-interface=\
    ether6 new-routing-mark=conn2 passthrough=no
add action=mark-connection chain=prerouting connection-state=new \
    in-interface=ether6 new-connection-mark=conn3 nth=5,3
add action=mark-routing chain=prerouting connection-mark=conn3 in-interface=\
    ether6 new-routing-mark=conn3 passthrough=no
add action=mark-connection chain=prerouting connection-state=new \
    in-interface=ether6 new-connection-mark=conn4 nth=5,4
add action=mark-routing chain=prerouting connection-mark=conn4 in-interface=\
    ether6 new-routing-mark=conn4 passthrough=no
add action=mark-connection chain=prerouting connection-state=new \
    in-interface=ether6 new-connection-mark=conn5 nth=5,5
add action=mark-routing chain=prerouting connection-mark=conn5 in-interface=\
    ether6 new-routing-mark=conn5 passthrough=no

/ip firewall nat
add action=masquerade chain=srcnat connection-mark=conn1 out-interface=ether1
add action=masquerade chain=srcnat connection-mark=conn2 out-interface=ether2
add action=masquerade chain=srcnat connection-mark=conn3 out-interface=ether3
add action=masquerade chain=srcnat connection-mark=conn4 out-interface=ether4
add action=masquerade chain=srcnat connection-mark=conn5 out-interface=ether5

/ip route
add comment=Auto-Add distance=1 gateway=192.168.1.1%ether1 routing-mark=conn1 \
    scope=255
add comment=Auto-Add distance=1 gateway=192.168.1.1%ether2 routing-mark=conn2 \
    scope=255
add comment=Auto-Add distance=1 gateway=192.168.1.1%ether3 routing-mark=conn3 \
    scope=255
add comment=Auto-Add distance=1 gateway=192.168.1.1%ether4 routing-mark=conn4 \
    scope=255
add comment=Auto-Add distance=1 gateway=192.168.1.1%ether5 routing-mark=conn5 \
    scope=255
add distance=1 gateway=192.168.1.1%ether3
add distance=1 gateway=192.168.1.1%ether1
add distance=1 gateway=192.168.1.1%ether5
add distance=1 gateway=192.168.1.1%ether2
add distance=1 gateway=192.168.1.1%ether4

/system script
add name=Aouto-Add-Route-work policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive source=":local \
    GWay ([/ip route nexthop get value-name=address number=0])\r\
    \n\r\
    \n\r\
    \n/ip route add distance=1 gateway=(\$GWay.\"%ether1\") routing-mark=conn1\
    \_scope=255 comment=\"Auto-Add\"\r\
    \n\r\
    \n/ip route add distance=1 gateway=(\$GWay.\"%ether2\") routing-mark=conn2\
    \_scope=255 comment=\"Auto-Add\"\r\
    \n\r\
    \n/ip route add distance=1 gateway=(\$GWay.\"%ether3\") routing-mark=conn3\
    \_scope=255 comment=\"Auto-Add\"\r\
    \n\r\
    \n/ip route add distance=1 gateway=(\$GWay.\"%ether4\") routing-mark=conn4\
    \_scope=255 comment=\"Auto-Add\"\r\
    \n\r\
    \n/ip route add distance=1 gateway=(\$GWay.\"%ether5\") routing-mark=conn5\
    \_scope=255 comment=\"Auto-Add\"\r\
    \n\r\
    \n\r\
    \n/ip route\tadd distance=1 gateway=(\$GWay.\"%ether1\")\r\
    \n\r\
    \n/ip route\tadd distance=1 gateway=(\$GWay.\"%ether2\")\r\
    \n\r\
    \n/ip route\tadd distance=1 gateway=(\$GWay.\"%ether3\")\r\
    \n\r\
    \n/ip route\tadd distance=1 gateway=(\$GWay.\"%ether4\")\r\
    \n\r\
    \n/ip route\tadd distance=1 gateway=(\$GWay.\"%ether5\")\r\
    \n"



You can contact me: plus.google.com/+PhallaCCMT; youtube.com/phallaccmt; facebook.com/Phalla.CCMT; twitter.com/PhallaCCMT and Phalla.CCMT@gmail.com
Previous
Next Post »