Multipath routing for backup gateway

mw flag

I have a debian server with 1 NIC, on my network I have two ISP's. It's possible to have two gateways on a single NIC, one Primaray Gateway and other for Backup/fallback in case of the internet on ISP1 goes down?

Example of diagram

If it's possible can you help me create such kind of routing table for it? I already try this, but not work

ip route add default  proto static scope global \
nexthop  via weight 1 \
nexthop  via weight 1
pt flag
In what way does it not work? What sort of diagnostics have you tried? I don't think multipath routing is what you want here, because Linux doesn't have any knowledge about which route is "up". You're probably looking for some sort of failover IP triggered by a connectivity test. You may want to investigate something like [keepalived](
mw flag
@larsks this doesnt work in way that I shutdown the Primaray Gateway and the traffic is not forward to the Backup Gateway.
mw flag
@TomTom what i want to achive is some kind of failolver between ISP, if the main gateway is down the traffic is automatically forward to Backup Gateway. This are two independent routers.
pt flag
@AndréBolinhas my suggestion (a failover mechanism) is *precisely* for the situation you've described (it provides a robust default route for your clients so that if one of your routers goes down, your clients continue to have internet access with minimal interruption in service). I don't think you'll get that behavior with multipath routing, which is more of a load balancing mechanism without some sort of external support for dead next-hop detection.
I sit in a Tesla and translated this thread with Ai:


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.