65. Mikrotik 4 WANs(Static IPs) Load Balancing and Fail Over(NTH Method)



/interface ethernet
set 0 name=Local
set 1 name=WAN1
set 2 name=WAN2
set 3 name=WAN3
set 4 name=WAN4

/ip address
add address=192.168.22.2/24 interface=WAN1
add address=192.168.23.2/24 interface=WAN2
add address=192.168.24.2/24 interface=WAN3
add address=192.168.25.2/24 interface=WAN4
add address=192.168.2.1/24 interface=Local

/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=103.28.3.187,8.8.8.8

/ip firewall mangle
add chain=prerouting in-interface=Local connection-state=new nth=4,1 action=mark-connection new-connection-mark=conn1 passthrough=yes comment="" disabled=no
add chain=prerouting in-interface=Local connection-mark=conn1 action=mark-routing new-routing-mark=conn1 passthrough=no comment="" disabled=no

add chain=prerouting in-interface=Local connection-state=new nth=4,2 action=mark-connection new-connection-mark=conn2 passthrough=yes comment="" disabled=no
add chain=prerouting in-interface=Local connection-mark=conn2 action=mark-routing new-routing-mark=conn2 passthrough=no comment="" disabled=no

add chain=prerouting in-interface=Local connection-state=new nth=4,3 action=mark-connection new-connection-mark=conn3 passthrough=yes comment="" disabled=no
add chain=prerouting in-interface=Local connection-mark=conn3 action=mark-routing new-routing-mark=conn3 passthrough=no comment="" disabled=no

add chain=prerouting in-interface=Local connection-state=new nth=4,4 action=mark-connection new-connection-mark=conn4 passthrough=yes comment="" disabled=no
add chain=prerouting in-interface=Local connection-mark=conn4 action=mark-routing new-routing-mark=conn4 passthrough=no comment="" disabled=no


/ip firewall nat
add chain=srcnat connection-mark=conn1 action=masquerade out-interface=WAN1 comment="" disabled=no
add chain=srcnat connection-mark=conn2 action=masquerade out-interface=WAN2 comment="" disabled=no
add chain=srcnat connection-mark=conn3 action=masquerade out-interface=WAN3 comment="" disabled=no
add chain=srcnat connection-mark=conn4 action=masquerade out-interface=WAN4 comment="" disabled=no


/ip route
add dst-address=0.0.0.0/0 gateway=192.168.22.1 scope=255 target-scope=10 routing-mark=conn1 comment="" disabled=no
add dst-address=0.0.0.0/0 gateway=192.168.23.1 scope=255 target-scope=10 routing-mark=conn2 comment="" disabled=no
add dst-address=0.0.0.0/0 gateway=192.168.24.1 scope=255 target-scope=10 routing-mark=conn3 comment="" disabled=no
add dst-address=0.0.0.0/0 gateway=192.168.25.1 scope=255 target-scope=10 routing-mark=conn4 comment="" disabled=no

add dst-address=0.0.0.0/0 gateway=192.168.22.1 comment="" disabled=no
add dst-address=0.0.0.0/0 gateway=192.168.23.1 comment="" disabled=no
add dst-address=0.0.0.0/0 gateway=192.168.24.1 comment="" disabled=no
add dst-address=0.0.0.0/0 gateway=192.168.25.1 comment="" disabled=no


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 »