Community discussions

MikroTik App
 
mihailJl
newbie
Topic Author
Posts: 38
Joined: Thu Jun 22, 2017 9:06 am

port targeting with two WAN

Sat Sep 16, 2017 1:41 am

I have two WAN connection and two LAN connection.
WAN1 - > x
WAN2 - > y
LAN1 -> 192.168.0.0/24
LAN2 -> 192.168.1.0/24
Also I have load balancing...
But I want LAN2 to use only WAN2 connection!
How can i do that?
 
User avatar
tomaskir
Trainer
Trainer
Posts: 1162
Joined: Sat Sep 24, 2011 2:32 pm
Location: Slovakia

Re: port targeting with two WAN

Sat Sep 16, 2017 2:33 am

You will need to configure policy based routing (PBR) in Mangle.

I suggest looking through the wiki and the forums, there are plenty of Mangle examples for PBR.
 
mihailJl
newbie
Topic Author
Posts: 38
Joined: Thu Jun 22, 2017 9:06 am

Re: port targeting with two WAN

Sat Sep 16, 2017 9:10 am

Thanks! I reviewed for PBR and I try this in my scenarie:
ip firewall Mangle add chain=prerouting src-address=192.168.0.0/24 action=mark-routing new-routing-mark=ThroughOnly_WAN2
Ip Route Add Dst-Address=0.0.0.0/0 Gateway=y(ip gate) Routing-Mark=ThroughOnly_WAN2
ip firewall nat chain=srcnat src-address=192.168.0.0/24 out-interface=WAN2 action=masquerade
How it looks to you?
 
User avatar
tomaskir
Trainer
Trainer
Posts: 1162
Joined: Sat Sep 24, 2011 2:32 pm
Location: Slovakia

Re: port targeting with two WAN

Sat Sep 16, 2017 1:17 pm

You need to do Mangle like this:

Code: Select all

/ip firewall mangle
add chain=prerouting src-address=192.168.0.0/24 connection-mark=no-mark action=mark-connection new-connection-mark=ThroughOnly_WAN2
add chain=prerouting src-address=192.168.0.0/24 connection-mark=ThroughOnly_WAN2 action=mark-routing new-routing-mark=ThroughOnly_WAN2
You will also want to do more in Mange than just that.
For example, correctly handle WAN->Router and WAN->LAN connections.

Look at this presentation, it should explain everything:
https://youtu.be/67Dna_ffCvc

Feel free to skip to around 6:30 - that's when the Mangle stuff starts.