Thiago Alvarez2020-03-26 09:20:20
Computer networks
Thiago Alvarez, 2020-03-26 09:20:20

2 main gateways on linux ubuntu?

How to make 2 default gateways per network interface in netplan?
registered routes and a metric in Netplan. But it does not switch to the second gateway if you disable the first one.

            dhcp4: no
                - to:
                  metric: 100
                - to:
                  metric: 101

[email protected]:~# routel
         target            gateway          source    proto    scope    dev tbl
        default                   static           ens33
        default                   static           ens33

Answer the question

In order to leave comments, you need to log in

1 answer(s)
hint000, 2020-03-26

Write a script that will be run by cron, check availability and reconfigure the route.
Of course (without a script) it will work under two conditions:
1) each gateway is connected through its own interface;
2) the link must physically fall on one of the interfaces, then the route will go through the other, in accordance with the metric; if there is no ping, but there is a link - even if you crack, it will be hammered by the minimum metric. I agree that this is pretty dumb for 2020, but as it is.
PS well, or use all sorts of dynamic routing protocols, this is a separate conversation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question