Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 
 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= gateway=center

On selected line i need to have iproute equivalent to ip route add default via dev gateway2 table gate2 but it routes via gateway1 interface ip route


/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.

share|improve this question
Please show /ip address, /ip firewall filter, /ip firewall nat, /ip route. –  lorsungcu Mar 4 at 4:47
@lorsungcu edited –  eri Mar 4 at 10:00
Your gateway is the same for all three default gw entries. Is that correct? I would start by removing and rebuilding those routes. If using winbox, it's pretty straightforward, if you're in the CLI, try this: ip route add dst-address= gateway= - you will need one of these for each interface, obviously. –  lorsungcu Mar 4 at 15:20
Your route to your ISP's gateway is also set for the same distance out both interfaces. There is quite a bit wrong with your current config - I will either need to know much more about what you want done, or more information on what your ISP is doing, or both. –  lorsungcu Mar 4 at 15:37
@lorsungcu i have two cables, on each cable traffic is filtered by ISP to X.Y.164.128 and X.Y.164.72. it may be dhcp-client or static. gateway is same. I cant bridge or bounding these. –  eri Mar 4 at 19:27

1 Answer 1

up vote 2 down vote accepted

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:

/ip route gateway= pref-src distance=1 
/ip route gateway= pref-src distance=2 

/ip route gateway= pref-src routing-mark=gate1 distance=1 
/ip route gateway= pref-src routing-mark=gate1 distance=2 

/ip route gateway= pref-src routing-mark=gate2 distance=1 
/ip route gateway= pref-src routing-mark=gate2 distance=2
share|improve this answer
Yea, i have the same problem with 2 cable modems. I ended up doing the % magic on both of my links and it works correctly. –  TiernanO Jun 1 at 18:48
% is magic! thanks a lot –  eri Jun 2 at 4:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.