F
F
foboss2015-02-10 12:45:55
linux
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:

.
                           ---------------
                     +----| 192.168.1.1   |--[port forwarding]-- [ WAN IP 1 ] -- (ISP 1)
 --------------      |     ---------------
| 192.168.1.20 | ----|
 --------------      |     ---------------
 0/0 via .1          +----| 192.168.1.254 | ---------[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)
C
Cool Admin, 2015-02-10
@foboss

You can specify two default routes with different metrics: unix.stackexchange.com/questions/35713/adding-two
-...
sample command route add default gw 192.168.1.254 metric 2
from, for example, ping to 8.8.8.8, i.e. we make a route to 8.8.8.8 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.

M
mayorovp, 2015-02-10
@mayorovp

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

V
Vlad Zhivotnev, 2015-02-10
@inkvizitor68sl

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