Mikrotik 2 Wan 1 Lan Income

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

/ip address

add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255


interface=Local
add address=192.168.1.2/24 network=192.168.1.0 broadcast=192.168.1.255
interface=WAN1
add address=192.168.2.2/24 network=192.168.2.0 broadcast=192.168.2.255
interface=WAN2
/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-
packet-size=512 servers=221.132.112.8,8.8.8.8
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-
mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-
mark=WAN2_conn
add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-
mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-
mark=to_WAN2
add chain=prerouting dst-address=192.168.1.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.2.0/24 action=accept in-interface=Local
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-
classifier=both-addresses-and-ports:2/0 action=mark-connection new-connection-
mark=WAN1_conn_1 passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-
classifier=both-addresses-and-ports:2/1 action=mark-connection new-connection-
mark=WAN2_conn_2 passthrough=yes
add chain=prerouting connection-mark=WAN1_conn_1 in-interface=Local action=mark-
routing new-routing-mark=to_WAN1
add chain=prerouting connection-mark=WAN2_conn_2 in-interface=Local action=mark-
routing new-routing-mark=to_WAN2
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.1.1 routing-mark=to_WAN1 check-
gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_WAN2 check-
gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.1.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2 check-gateway=ping
/ip firewall nat
add chain=srcnat out-interface-list=WAN action=masquerade

good one

/ip route
add check-gateway=ping dst-address=0.0.0.0/0 gateway=ISP1 table=main ( checks to
see if wan connection is active every 10 secs )
add check-gateway=ping dst-address=0.0.0.0/0 gateway=ISP2 table=main ( checks to
see if wan connection is active every 10 secs )
add dst-address=0.0.0.0/0 gateway=ISP1 table=useWAN1 distance=2 { PCC traffic
marked for ISP1 goes through ISP1 }
add dst-address=0.0.0.0/0 gateway=ISP2 table=useWAN1 distance=4 { PCC traffic
marked for ISP1 goes out ISP2 when ISP1 is not available }
add dst-address=0.0.0.0/0 gateway=ISP2 table=useWAN2 distance=2 { PCC traffic
marked for ISP2 goes through ISP2 }
add dst-address=0.0.0.0/0 gateway=ISP1 table=useWAN2 distance=4 [edit had "2"
earlier by mistake] { PCC traffic marked for ISP2 goes out ISP1 when ISP1 is not
available }
Next we need to mangle traffic Note you stated that WAN2 had more throughput, so
the router selects WAN2 twice for every single selection of WAN1 for sessions.
/mangle
add chain=prerouting action=mark-connection connection-mark=no-mark in-interface-
list=LAN \
new-connection-mark=Mark-WAN1 dst-address-type=!local passthrough=yes \
per-connection-classifier=both-addresses:3/0
add chain=prerouting action=mark-connection connection-mark=no-mark in-interface-
list=LAN \
new-connection-mark=Mark-WAN2 dst-address-type=!local passthrough=yes \
per-connection-classifier=both-addresses:3/1
add chain=prerouting action=mark-connection connection-mark=no-mark in-interface-
list=LAN \
new-connection-mark=Mark-WAN2 dst-address-type=!local passthrough=yes \
per-connection-classifier=both-addresses:3/2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
add chain=prerouting action=mark-routing connection-mark=Mark-WAN1 \
new-routing-mark=useWAN1 passthrough=yes
add chain=prerouting action=mark-routing connection-mark=Mark-WAN2 \
new-routing-mark=useWAN2 passthrough=yes

To ensure any incoming traffic originating from outside the router, IF ANY? (could
be port forwarding, could be wireguard VPN remote in ) you would need some
additional rules.
Optional......
add chain=prerouting action=mark-connection connection-mark=no-mark in-
interface=ISP1 \
new-connection-mark=Incoming-WAN1 passthrough=yes
add chain=prerouting action=mark-connection connection-mark=no-mark in-
interface=ISP2 \
new-connection-mark=Incoming-WAN2 passthrough=yes
++++++++++++++++++++++++++++++++++++++++++
add chain=output action=mark-routing connection-mark=Incoming-WAN1 \
new-routing-mark=useWAN1 passthrough=no
add chain=output action=mark-routing connection-mark=Incoming-WAN2 \
new-routing-mark=useWAN2 passthrough=no

>>>>>>>>>>>>>>>>>>

You might also like