Best method to load balance 2 internet line?

I cannot se difference, when i disconnect and than reconect the modem, the stay active gateway with bigger distance. I noticed, when after reconecting change something on any gateway, it is enough to switch off check gateway, after click on ok is active the gateway with lower distance.

chupaka,
i found this thread looking for a simple way to failover two connections(one similar to this examples in which a external router brings up the adsl connection and the other one is standard ethernet).
(btw, i have to finish reading the documentation about scopes and target scopes)

i have a some questions after reading this:

  1. i see you generate routing marks, should i need to do anything else on the roputing rules to forward users traffic through the different connections?
  2. before these routes, i assume i’ll need a MASQ rule for each wan, right(what happens to masquerading in the routed connection case seeing as the modem gives a private DMz ip to the routeros?)?
  3. what about default gateway for the routeros itself?
  4. for incoming connections i assume i’ll need a DSTNAT/forward rule per connection?

regards,
Guillermo

  1. no additional routing rules needed
  2. it depends on the modem config. if your modem will route your VPN addresses back to your router - then you’d better not to double-NAT =)
  3. use those default routes but without ‘routing-mark’ =)
  4. well, you may use one NAT rule, but anyway you will need to mark connections according to the incoming interface, so that it will be routed back via that interface

fu**, you are so fast.. xD

point 4, for wxample like this:

/ip firewall mangle
add action=mark-connection chain=input comment=“IN router1” disabled=no in-interface=ether2-ISP1 new-connection-mark=ISP1_conn passthrough=no
add action=mark-connection chain=input comment=“IN router2” disabled=no in-interface=ether3-ISP2 new-connection-mark=ISP2_conn passthrough=no

Hello,
I have received answer from support. I get recommendation to change some routing marks. The second recommendation was to change check-gateway from ping to arp. I have tried this, but I lost connection to internet. What do you thing about this, could this change ping to arp be a solution? Nothing else was in answer from support.

I think you can’t use arp here, because the gateways are on internet.

definitely, you may use only ‘ping’ for checking

Thank you for answer. I think the same, that arp cannot work, but it was official answer from support. Hopefully support will come with something “better”.

treborr, what does “/ip route nexthop print” shows when problem appears? and also during normal operation…

During normal function it shows:
[ro3ot1@MikroTik] > /ip route nexthop print detail
0 address=93.158.134.3 gw-state=recursive forwarding-nexthop=192.168.0.1 scope=30 check-gateway=icmp gw-check-ok=yes
1 address=192.168.0.1 gw-state=reachable scope=10 check-gateway=none
2 address=192.168.10.1 gw-state=reachable scope=10 check-gateway=none
3 address=213.180.204.3 gw-state=recursive forwarding-nexthop=192.168.10.1 scope=30 check-gateway=icmp gw-check-ok=yes

when one modem is disconnected:
[ro3ot1@MikroTik] > /ip route nexthop print detail
0 address=93.158.134.3 gw-state=recursive forwarding-nexthop=192.168.0.1 scope=30 check-gateway=icmp gw-check-ok=yes
1 address=192.168.0.1 gw-state=reachable scope=10 check-gateway=none
2 address=192.168.10.1 gw-state=unreachable scope=10 check-gateway=none
3 address=213.180.204.3 gw-state=recursive forwarding-nexthop=192.168.0.1 scope=30 check-gateway=icmp gw-check-ok=yes

a when the modem is reconnected:
[ro3ot1@MikroTik] > /ip route nexthop print detail
0 address=93.158.134.3 gw-state=recursive forwarding-nexthop=192.168.0.1 scope=30 check-gateway=icmp gw-check-ok=yes
1 address=192.168.0.1 gw-state=reachable scope=10 check-gateway=none
2 address=192.168.10.1 gw-state=reachable scope=10 check-gateway=none
3 address=213.180.204.3 gw-state=recursive forwarding-nexthop=192.168.10.1 scope=30 check-gateway=icmp gw-check-ok=yes

disconnected?.. “gw-check-ok” is always “yes”… have you waited a minute?..

is 192.168.10.1 static address?..

and after that i have to build a route rule using the connection marks: ISP2_conn /ISP1

i think i’m getting the hang of this(it’s bee a while since i used a ROS and never for dual-wan failover without balancing)

Yes i always wait cca 1 minute. Yes the 192.168.10.1 is static address.

hmmm… what version of ROS?.. I’m wondering why “gw-check-ok=yes”… can you ping 213.180.204.3 when modem is disconnected?..

Version of ROS is 4.9 from 29.4.2010
Yes i can ping 213.180.204.3
the begin of tracert
1 < 1 ms < 1 ms <1 1 ms 192.168.0.1 - this is ip address of second modem.

Thank You

hmmm… try to change target-scope of all default routes to 10 (it should not be 30)…

Thank you for your help.
I have changed the target-scope to 10 for all default routes. It still the same after reconnecting of modem :frowning:

and what about ping?

Solution for issue: not active routes with shorter distance after reconnecting modem.

It is not my solution, all Thanks belongs to Chupaka.
Thank You.

To the solution which is posted in this topic on the first page are added the following two routes:

/ip route
add dst-address=213.180.204.3 type=blackhole distance=20 scope=30 target-scope=10
add dst-address=93.158.134.3 type=blackhole distance=20 scope=30 target-scope=10

Here is the output of complete solution:
/ip route print detail

  • Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, B - blackhole, U - unreachable, P - prohibit
    0 A S dst-address=0.0.0.0/0 gateway=213.180.204.3 gateway-status=213.180.204.3 recursive via 192.168.10.1 5-gw-asus check-gateway=ping distance=1 scope=30 target-scope=10 routing-mark=to_ISP1
    1 S dst-address=0.0.0.0/0 gateway=93.158.134.3 gateway-status=93.158.134.3 recursive via 192.168.0.1 4-gw-cisco check-gateway=ping distance=10 scope=30 target-scope=10 routing-mark=to_ISP1
    2 A S dst-address=0.0.0.0/0 gateway=93.158.134.3 gateway-status=93.158.134.3 recursive via 192.168.0.1 4-gw-cisco check-gateway=ping distance=1 scope=30 target-scope=10 routing-mark=to_ISP2
    3 S dst-address=0.0.0.0/0 gateway=213.180.204.3 gateway-status=213.180.204.3 recursive via 192.168.10.1 5-gw-asus check-gateway=ping distance=10 scope=30 target-scope=10 routing-mark=to_ISP2
    4 A S dst-address=0.0.0.0/0 gateway=93.158.134.3 gateway-status=93.158.134.3 recursive via 192.168.0.1 4-gw-cisco check-gateway=ping distance=15 scope=30 target-scope=10
    5 S dst-address=0.0.0.0/0 gateway=213.180.204.3 gateway-status=213.180.204.3 recursive via 192.168.10.1 5-gw-asus check-gateway=ping distance=15 scope=30 target-scope=10
    6 A S dst-address=93.158.134.3/32 gateway=192.168.0.1 gateway-status=192.168.0.1 reachable 4-gw-cisco distance=1 scope=10 target-scope=10
    7 SB dst-address=93.158.134.3/32 type=blackhole distance=20
    8 ADC dst-address=192.168.0.0/24 pref-src=192.168.0.240 gateway=4-gw-cisco gateway-status=4-gw-cisco reachable distance=0 scope=10
    9 ADC dst-address=192.168.1.0/24 pref-src=192.168.1.1 gateway=1-green gateway-status=1-green unreachable distance=0 scope=200
    10 ADC dst-address=192.168.5.0/24 pref-src=192.168.5.1 gateway=2-orange gateway-status=2-orange unreachable distance=0 scope=200
    11 ADC dst-address=192.168.7.0/24 pref-src=192.168.7.1 gateway=3-blue gateway-status=3-blue unreachable distance=0 scope=200
    12 ADC dst-address=192.168.10.0/24 pref-src=192.168.10.12 gateway=5-gw-asus gateway-status=5-gw-asus reachable distance=0 scope=10
    13 A S dst-address=213.180.204.3/32 gateway=192.168.10.1 gateway-status=192.168.10.1 reachable 5-gw-asus distance=1 scope=10 target-scope=10
    14 SB dst-address=213.180.204.3/32 type=blackhole distance=20

yep, after adding those blackhole routes recursive routes are recalculated correctly - to be fixed in next version =)