If I have two network devices, how do I know which is being used for any requested connection out.

With this :

ip r
  default via dev wlp3s0 proto static 
  default via dev wlx00e04c221395 proto dhcp src metric 600 dev wlp3s0 proto kernel scope link src dev wlx00e04c221395 proto kernel scope link src dev wlx00e04c221395 proto dhcp scope link src metric 600 

I have two default routes. Will system always use the first as listed by the ip r command?


I think the discussion in the comments to the other answer deserve their own answer:

First, while you can list the routing table with ip route or route -n and work out yourself what's likely going to happen, it's easier to just ask the kernel with ip route get a.b.c.d to go through the routing tables (yes, there's more tables in a modern Linux system, and route -n only shows the main table) and tell you the outcome.

Second, a rule of thumb for designing a network is "each host only gets a single network interface into each subnet it is connected to". Here VMs, network namespaces etc. count as additional "hosts", even if they run on the same hardware.

A corollary is "no, you don't assign multiple IPv4 addresses to the same network interface" (unless you know what you are doing, but then you do that at your own peril).

The reason is that nothing is won by making a subnet accessible through different network interfaces: It will go into the same subnet one way or the other.

If you violate these rules, as you did above, where you apparently have two WLANs connected to the same subnet: dev wlp3s0 proto kernel scope link src dev wlx00e04c221395 proto kernel scope link src 

then what happens is not defined. As you can see, the linux kernel happily picks one of the network interfaces at random for destinations 10.0.0.*.

So either these are really connecting to two different WLANs. In that case, change the IP range of one of the WLANs, e.g. to Or, they are the same WLAN, and in that case having two WLAN adapters makes no sense.

It's similar with the default rule. You should only have a single default rule; having multiple rules means the behaviour is undefined, and a rule gets picked at random. This means that packets in one connection are randomly sent with different parameters (e.g. source addresses), and the host on the other hand will only recognize one set of parmameters (the one the connection was opened with), will drop the other packets, and will consider the missing packets as lost packets. That's because the standard internet protocols are "single homed". There are multi-homed protocols (like SCTP or multi-home TCP extensions), but they are currently not used widely enough to be useful.

So no, you can't use two ISPs to connect to the internet and make "the internet faster" (unless you have some hard way of deciding which connection to use, e.g. by destination address). That's a FAQ that gets asked every week or so.

I hope that answers all (or at least most of) the questions you didn't ask in your original question.

  • Perfect. Thank you. I'm one of those mad tinkers whose path of learning will frequently blow up the lab. But making the internet faster wasn't the goal. I feel that you're taking potshots from your lofty presumptions. You were doing great up til then. – Stephen Boston Jun 1 at 13:39
  • 1
    Sorry, no potshotting intended - I've just seen too many of the same type of questions on this site, and it gets a bit tiring to always answer the same ones. Combine that with XY questions (which also happen frequently), and the inability to directly talk to the person who is asking the question, and then it just speeds up thinks to make assumptions (or presumptions, or take potshots, if you want to put it that way). Even if they turn out to be wrong, as in your case. And there's nothing wrong with blowing up the lab :-) – dirkt Jun 1 at 14:27

Check your route table with below command, here Metric column normally decide what is the routing priorities,

$ route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    50     0        0 eth1         UG    100    0        0 eth0

This priority is depending on sequence of interface come up after reboot/start, you can also influence the priority with below command

sudo ifmetric <interface> <priority>
  • Even better, use ip route get a.b.c.d to find out which network device the kernel will use to reach IP address a.b.c.d. This also works when the routing table isn't that obvious as in your example... – dirkt May 31 at 17:19
  • @dirkt Interesting. This shows consistently ( 5 cycles) a different device used to route to my DNS than to my gateway. How's that? – Stephen Boston May 31 at 17:24
  • @StephenBoston: Two identical routes with same metric for the target address? That's never a good idea... the answer is usually "fix your network setup so this doesn't happen". – dirkt May 31 at 17:27
  • @dirkt Do you mean that ip r should show only one default for the routing table? Or that there should be only one default for the device? – Stephen Boston May 31 at 22:34

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.