1

Currently I am using Alma-Linux, where I need to create 2 default gateways for the same NIC. Main intent of 2 default gateway configuration is.. when any one of the gateways is down then it will fall back to other working gateway

Gateway Configuration Below IPs are used for routing

  1. 11.12.13.2 (default gateway - with lower metric value 30)
  2. 11.12.13.1 (default gateway configured via static route - with higher metric value 40)

Both IPs are ping-able.

For testing fail over scenario, I disabled the gateway ip with lower metrics IP(11.12.13.2) and performed the traceroute command on a random remote host which is in different subnet.

command : traceroute 17.18.19.2

but traceroute result is destination unreachable.

In this scenario, I assume packets will go through default gateway route 11.12.13.1 ip as a fall back option. since configured gateway is down. It is not working as I expected.

Note: In windows, gateway fall back is happening irrespective of metric values.

13
  • Why ask a new question when there was serverfault.com/questions/1141388/… ?
    – A.B
    Commented Aug 19, 2023 at 18:59
  • As I wrote in your other question, there's at least a mistake on the additional "default" route. But in this question you write no output from the result of a command, so any mistake like that one is now invisible. Fixing this mistake won't make it work though.
    – A.B
    Commented Aug 19, 2023 at 19:42
  • @A.B Yeah my last question you are talking about is resolved by using 0.0.0.0/0 as destination IP. This question is specifically asked in the context of metric value of gateways. Commented Aug 20, 2023 at 11:25
  • I can't tell the difference between the two questions by reading them. Moreover you didn't answer to nor delete the other question while you tell it's solved.
    – A.B
    Commented Aug 20, 2023 at 11:27
  • @A.B Imagine two default gateways are assigned with metric values 10 and 20 respectively. When default gateway with lower value 10 is down then expectation is other gateway with value 20 is should come take over automatically without user interaction Commented Aug 20, 2023 at 11:40

1 Answer 1

1
+50

There is no fully automatic ready-made fall back in Linux and it was never there. You have wrong expectation of what Linux could do for you.

Routing code doesn't track the availability of the gateway. In case several similar routes with different metrics are present, numerically lower metric is always selected, with no additional logic that can consider the state of that gateway. It's because nothing checks whether gateway is still alive, the system doesn't care about the gateway. Even if the gateway specified in the route is down, nothing in the system will know about this, route will still exist and the system will use it.

You need some external mechanism which will ping or otherwise check gateways and torn down their routes if not available. Only then, without the route to the failed gateway, next best route will be considered.

3
  • How about the behaviour when we use 2 default gateways on 2 DIFFERENT interfaces in a same system? Commented Aug 30, 2023 at 3:13
  • Nowhere in my answer I am saying anything about interfaces. Routing includes the stage of selection of outgoing interface, which implies when it is started there is no any knowledge of interfaces. So this simply doesn't matter. Commented Aug 30, 2023 at 4:31
  • I forgot interesting "corner" case. If the interface where gateway is defined goes down (loses carrier) all routes associated with it also disappear. In that case next best route will be considered. A smart router itself can put down its interface to signify to clients it has no internet access, to exploit this behaviour, but any switch between the router and a client device will break such setup. Personally I think the availability of the gateway or status of its interface is not sufficient for robust route selection; you have to check if there is actually internet behind the gateway. Commented Sep 3, 2023 at 17:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .