Page 1 of 1

Forcing single IP to use specific WAN

Posted: Tue Feb 17, 2015 4:15 pm
by sebdar
Hi ,
I wonder if someone can help me.
I have 3 interfaces configured.

ethernet 2 WAN1 (192.168.5.3) (behind there is ADSL router 192.168.5.1)
ethernet 3 WAN2 (192.168.3.3) (behind there is aDSL router 192.168.3.1)
ethernet 5 LAN (192.168.1.254) connected to a network (192.168.1.0)

IP routes are set as follow:

First:
Dst. address: 0.0.0.0/0
Gateway: 192.168.5.1

Second:

Dst. address: 0.0.0.0/0
Gateway: 192.168.3.1

I have also set up 2 NAT rules to masquerade Src. Address 192.168.1.0/24 for both WAN Out Interfeces.

Now when I will disconnect WAN1 interface, clients on the LAN network automatically will switch to WAN2.

What I'm trying to achieve is to force a single IP (for example 192.168.1.244) to use only specific WAN (for example WAN1).
How can I achieve that?

Any help appreciated.

Re: Forcing single IP to use specific WAN

Posted: Tue Feb 17, 2015 4:30 pm
by sergejs
Just configure /ip firewall nat rule, that specifies that client src-address is always masqueraded over specific WAN.


Another thins is that you need additional configuration for such configuration,
First:
Dst. address: 0.0.0.0/0
Gateway: 192.168.5.1

Second:

Dst. address: 0.0.0.0/0
Gateway: 192.168.3.1
otherwise first gateway will be used all the time.

Re: Forcing single IP to use specific WAN

Posted: Wed Feb 18, 2015 10:39 am
by sebdar
What do you mean by "Another thins is that you need additional configuration for such configuration"?

My NAT config for the single IP looks as follow:

Chain: scr-nat
Src. address: 192.168.1.81
Out. Interface: WAN1
Action: masquerade

Is that what I'm looking for?

Re: Forcing single IP to use specific WAN

Posted: Wed Feb 18, 2015 10:51 am
by sergejs
What do you mean by "Another thins is that you need additional configuration for such configuration"?
If you just set two default gateways, only one of them is going to work (without additional configuration).

Re: Forcing single IP to use specific WAN

Posted: Sat Feb 21, 2015 10:11 pm
by Cetalfio
sergejs invites you to explore this topic, have you looked at some examples on wiki.mikrotik.com.
This can help you
http://wiki.mikrotik.com/wiki/Load_Balancing

In the past I used the ECMP and to force some LAN ip to use specific gateway I did:

/ip firewall mangle add chain=prerouting action=mark-routing new-routing-mark=goGW1 passthrough=no src-address=LAN-IP-Address192.168.1.244

/ip route add dst-address=0.0.0.0/0 gateway=192.168.5.3 gateway-status=192.168.5.3 distance=1 scope=30 target-scope=10 routing-mark=goGW1

cetalfio

Re: Forcing single IP to use specific WAN

Posted: Sun Feb 22, 2015 4:50 am
by jprasad
you can use mangle in the firewall tab.

put your source ip adress go to action tab choose mark routing then make routing mark "wan1"

now go to routes
make route to 0.0.0.0/0
gateway 192.168.5.1%(YOUR WAN1 INTERFACE NAME) (the % forces it to use that interface)
routing mark "wan1"

then your masqurade is like normal