Similar questions but no answer:

On Linux, when two routes have the same metric, which one will be used? I found this is documented for Windows ("If multiple interfaces of the same speed have the same lowest interface metric, then, based upon the binding order, the default gateway of the first network adapter is used. The default gateway for the second network adapter is used when the first is unavailable.") but cannot find how Linux is handling this.

I guess the answer is in the code but it's not obvious.


  • AFAIK it's undefined, so even if you find out how it works for a particular Linux version, you shouldn't rely on that staying the same ... so just don't use default routes with the same metric. If this is an XY question, and you want to do load balancing on several gateways: There are ways to do that. – dirkt Sep 12 at 10:47

You should avoid having two (or more) default routes. This is simple enough when using static IP addressing. Just don't put anything into the "gateway" field. If you're using DHCP-assigned addresses, you could reconfigure the DHCP server to only advertise one default route, or configure you're Linux machine to ignore one of the default routes. I routinely do the later with a simple NetworkManager command, like this:

$ nmcli connection modify "eth1" ipv4.ignore-auto-routes yes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.