I have 2 static addreses (a.b.c.72/24
and a.b.c.128/24
) on gateway1
and gateway2
interfaces. ISP have one gateway a.b.c.1
. I can use a.b.c.72
only on gateway1
, a.b.c.128
only on gateway2
.
How to get a.b.c.128 working? I want route some local machines via second interface. I know some ways to route via different gateways in mikrotik. In linux i can specify dev parameter to route.
I added routing tables and rules, but it still routed via gateway2.
/ip dhcp-client print
Flags: X - disabled, I - invalid
# INTERFACE USE ADD-DEFAULT-ROUTE STATUS ADDRESS
0 gateway1 yes no bound X.Y.164.72/24
1 gateway2 yes no bound X.Y.164.128/24
/ip route
add distance=51 gateway=X.Y.164.1 pref-src=X.Y.164.128 routing-mark=gate2
add distance=1 dst-address=X.Y.164.0/24 gateway=gateway2 pref-src=X.Y.164.128 routing-mark=gate2
add distance=52 gateway=X.Y.164.1 pref-src=X.Y.164.72 routing-mark=gate1
add distance=1 dst-address=X.Y.164.0/24 gateway=gateway1 pref-src=X.Y.164.72 routing-mark=gate1
add distance=52 gateway=X.Y.164.1
add distance=10 dst-address=10.0.0.0/8 gateway=center
On selected line i need to have iproute equivalent to ip route add default via 109.60.164.1 dev gateway2 table gate2
but it routes via gateway1 interface
NAT
/ip firewall nat
add action=masquerade chain=srcnat out-interface=gateway1
add action=masquerade chain=srcnat out-interface=gateway2
Mangle is clean now. It had marks connections from and routes for selected clients. It is not a problem and workswith different gateways.
Due to the fact that both links have the same IP gateway, you must set in some way the interface you want to use in your routing tables. The syntax is the following: gateway=[ip]%[interface] + specific preferred source; given this fact, in your router these routes should look like the following:
If you need to route to the same gateway via different interfaces:
Do the same for another sub-net Go to IP routes and select which mark you want to assign to the interface. Select routing mark
Do the same for another route. Enjoy the separate routes on your, it works on the same bridge as well.