How does Linux determine which network interface to use, when both are connected to the same network?

Note that this isn't a question on routing. I'm familiar with how that works. This is if, say, I have my laptop connected to my wireless router through both my ethernet card and my wireless card, or if I have two ethernet cards both connected to the same router.

I can say from experience that in my case, my laptop seems to favor the ethernet card (eth0) over the wireless (eth1--I know that's not a typical name for a wireless interface, but that's what I have), but I was wondering, how does it decide that? If it just picks from the lowest numbered interface, what if the two choices are, say, eth0 and wlan0?

Edit: @Nils has pointed out that this is still a matter of routing, and the routing table provides the answer (see his answer). This still leaves my original question, but in a different form. What determines the order of entries in the routing table in Linux? For example, here is my routing table while connected to both interfaces:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface         UG        0 0          0 eth0     U         0 0          0 eth0   U         0 0          0 eth0   U         0 0          0 eth1

It's clear that eth0 is higher priority in the table than eth1 for destinations in the local network, but is that decided in Linux from link latency, link throughput, even the interface name, or what? (The same question could go for why eth0 is the interface for the default route.)

1 Answer 1


Well - this IS a routing-question.

The answer is simple: The first entry that will give the best routing-entry is "the winner". So look at netstat -rn to see which interface is first.

Update: The network-inferface-routing-settings normally get set up during system startup. So the startup order of network devices will be the order in that table. With PCI-devices these normally are being processed by lowest slot-number first. External devices (e.g. USB) normally come later on.

But the exact order depends on the network-startup-script of your Linux flavour (this is something where they very much differ).

BTW: If you want to make use of your two links, you should go for bonding. There you can set up the order of usage for your links.

  • 1
    That makes sense. When I said routing, what I meant was it wasn't simply a matter of picking which interface is connected to the destination network (directly or indirectly), since both are. I should have been more careful with my terminology. Thanks for the helpful tips (especially about bonding). This still leaves my original question, though, in a slightly different form. How is the order of routing entries determined in Linux (I edited the original question)? Dec 2, 2012 at 23:25
  • @Dominick I updated my answer accordingly. What distribution and what major-version are you using?
    – Nils
    Dec 3, 2012 at 21:42
  • Ah. I didn't realize it could vary so much between distributions. I looked all over for information on this, but all I found were articles on how to set routing entries, not how the original ones are determined. I'm using Xubuntu 12.04. This does raise one other question (small though; I feel very enlightened from your answer :-) ). If I'm connected via wireless (eth1) and later connect via Ethernet (eth0), the default route and top entries in the routing table go back to eth0. This seems to go against your answer. Am I misunderstanding, or is that a NetworkManager idiosyncrasy, or what? Dec 4, 2012 at 0:52
  • @Dominick Ubuntu is very special. It does some magic stuff in the background when plugging/unplugging network devices. I guess it restarts the whole network stack there. (I normally use SLES/RH and am not too deep into Ubuntu)
    – Nils
    Dec 4, 2012 at 21:29

You must log in to answer this question.

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