foboss2015-02-10 12:45:55
foboss, 2015-02-10 12:45:55

2 Linux default gateways on the same subnet with different metrics on the same interface. Is it possible to?

There is one rather wonderful machine with one address in the LAN, which has 2 WAN addresses from two different routers from two different providers. From the Internet, this horror is available at both addresses and works great.
It looks something like this:

                     +----|   |--[port forwarding]-- [ WAN IP 1 ] -- (ISP 1)
 --------------      |     ---------------
| | ----|
 --------------      |     ---------------
 0/0 via .1          +----| | ---------[Rev.NAT]-- [ WAN IP 2 ] -- (ISP 2)

The problem, as expected, occurs with outgoing traffic when ISP 1 (default gw) disappears. To complicate matters, ISP crashes do not render the .1 and/or .254 gateways themselves unavailable.
Will the network work if you specify 2 gateways with different metrics to the same network interface? Will traffic go to the second gateway?
It is clear that you can manually switch gw to .254 and everything will work. But can it be automated?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Cool Admin, 2015-02-10

You can specify two default routes with different metrics: unix.stackexchange.com/questions/35713/adding-two
sample command route add default gw metric 2
from, for example, ping to, i.e. we make a route to strictly through the first provider, we make a ping check script and if it is not there, we change the metrics for the def routes. In the details of the implementation of the script for niks, I will not tell you.

mayorovp, 2015-02-10

Whose routers? In the "right" networks, they must solve such problems among themselves ...

Vlad Zhivotnev, 2015-02-10

chris.olstrom.com/howto/setup-dual-wan you should read about this carefully.
Well, the rest of Google on the topic "linux 2 wan".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question