Score:1

Alma Linux - Gateway fall back is not working, when gateway IP with lower metrics is down

no flag

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.

A.B avatar
cl flag
A.B
Why ask a new question when there was https://serverfault.com/questions/1141388/alma-linux-static-route-configuration-is-not-working-as-fall-back-mechanism-wh ?
A.B avatar
cl flag
A.B
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.
cpp_learner avatar
no flag
@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.
A.B avatar
cl flag
A.B
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.
cpp_learner avatar
no flag
@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
A.B avatar
cl flag
A.B
That's what you want, not what can be done (by a few clicks). Anyway fix the former question first. Btw, I have no answer to provide, but someone might.
cpp_learner avatar
no flag
But automatic fail over switch not happening in case of 2 different metric values. If 2 gateways have SAME value then it's working. Is it the expected behavior in linux
A.B avatar
cl flag
A.B
Where did you read this? Are they on the same interface or on different interfaces (not your case with a single interface)?
cpp_learner avatar
no flag
I tried practically in my linux system with different combinations and came to this conclusion. When two gateways are up and running then communication is happening through the gateway with lower metric value. If I bring that gatewAy down other gateway with value 20 should take care of communication automatically. That's not happening it's my observation. I tried on same interface it's my use case. I tested the same in windows it's working fine
cn flag
Does this answer your question? [Alma Linux -Static route configuration is not working as fall back mechanism, when default gateway is down](https://serverfault.com/questions/1141388/alma-linux-static-route-configuration-is-not-working-as-fall-back-mechanism-wh)
cpp_learner avatar
no flag
@GregAskew: Not answered yet. This question is variation of my previous question though both are related to gateway failover scenario but here question is related to it's expected behavior in case of 2 gateways configured with 2 different metrics on the same single interface
Alexander Pavluchenko avatar
pl flag
In Linux, only the default route with the lowest metric will be considered, and if that fails, it will not automatically fall back to the next highest metric. However, you can achieve your desired behavior by using some more advanced routing tools and methods, such as iproute2 and routing tables.
Alexander Pavluchenko avatar
pl flag
Install iproute2. Configure the primary default route: sudo ip route add default via 11.12.13.2 dev eth0 metric 30 Configure the secondary default route: sudo ip route add default via 11.12.13.1 dev eth0 metric 40 Add routing tables: Edit /etc/iproute2/rt_tables: Add the following at the end: 10 rt1 20 rt2 Set up rules and routes: sudo ip rule add from all lookup rt1 prio 100 sudo ip rule add from all lookup rt2 prio 200 sudo ip route add default via 11.12.13.2 dev eth0 table rt1 sudo ip route add default via 11.12.13.1 dev eth0 table rt2
Score:1
za flag

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.

cpp_learner avatar
no flag
How about the behaviour when we use 2 default gateways on 2 DIFFERENT interfaces in a same system?
Nikita Kipriyanov avatar
za flag
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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.