Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If your pc (lets assume windows) is connected via a wired LAN and has a USB dongle that supplies 3G internet, how does your pc know which connection to use when browsing the web? Does linux follow the same rules as windows?

share|improve this question

Any time multiple network connections are involved (on any OS), the routing table identifies which connection to use.

I'm going to explain the routing table using a Linux example, but Windows is effectively the same. The main difference is how it labels the interfaces.

Let's say you have 3 network connections that each are connected to different networks, like this:

eth0 ->
eth1 ->
eth2 ->

By default, as your system configures the network connections, it will add routes for each of these networks to your routing table. Here's an example routing table for a server with the connections shown above:

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

So, if you want to connect to one of those networks, your Linux system will decide which connection to use based on the destination network. If you want to connect to a server with the IP, it will use eth0. If you want to connect to, it will use eth2.

So, what about networks that aren't specifically listed in the routing table? Well, that's where the default route comes in. Notice the last line in that routing table:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
...         UG    0      0        0 eth0

The short version is that any traffic destined for a network that isn't specifically listed in the routing table will be sent through the default route. In the example above, that is eth0, sending specifically to the router at

The longer version is that routing decisions are based on network prefix length. A given packet will follow the route with the most specific matching destination. Here is an example list of networks in CIDR notation that range from most to least specific:  <-- Most specific      <-- Least specific

So, given a destination IP of, the most specific matching range in the above list is, so the route for that network would be followed. If the destination is, the most specific matching range is (which is the default route). Once the routing decision is made, then the system will send the traffic down the appropriate network connection.

This got a little long-winded, but I hope that it explains things. In general, the default route decides what connection internet traffic will go through. The default route is configured differently on Windows vs Linux, but ultimately everything works on the same underlying routing mechanism.

share|improve this answer
+1 - Great detail. I added to my answer that you have the definitive info for linux. – JNK Sep 9 '10 at 15:59

Windows using binding order.

This is basically an ordered list of connections to try. Windows will try the first connection, and if unsuccessful will go to the next, etc. For internet it will almost always use the first. The second connection may be used if you are on a LAN and a WAN, and the second NIC connects to a certain IP schema (192.168.4.X for example) that is not a part of the first NIC.

I don't know enough about Linux networking to address that, but some quick searching shows it may work similarly. I'll check some more and come back with an edit if I have a definitive answer.


baumgart's answer below is better for Linux...

share|improve this answer
Centos and Ubuntu – rumz Sep 9 '10 at 13:43
@ roomy - added detail to the answer. – JNK Sep 9 '10 at 13:52
FYI, Linux bonding is not what you're looking for here. Bonding ties multiple interfaces together to provide redundancy to a single switch, but using multiple NICs on different networks does not work in bonding. – baumgart Sep 9 '10 at 15:27
@Baumgart - thanks for the clarification. Can you offer any info on the proper command? – JNK Sep 9 '10 at 15:34
Well, as my answer below says (in painfully horrendous detail), it's all about the routing table. Every distribution configures the network slightly differently, but they all set the default route somehow. Doing it manually at the command line uses the 'route' command, typically 'route add default gw' (or whatever IP is your default gateway). – baumgart Sep 9 '10 at 15:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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