I've two interfaces: eth0 and wlan0 on a notebook.

Possible use cases:

  • eth0 grants me Internet access, and wlan0 is currently connected to a router which does not have Internet-connectivity. For development purposes, I need to connect to the wlan0 by default, but use eth0 for surfing
  • eth0 and wlan0 are both connected to the Internet. For a torrent application, eth0 should be used for speed, but for portability of the notebook, SSH should have a connection over wlan0
  • eth0 is a wire connection, wlan0 is a wireless one. Sensible data should be transferred over eth0, but other traffic can go over wlan0 as well.

Is there a way to force applications (like nc.traditional or firefox) to use a certain network interface? A wrapper like example-wrapper eth0 program is fine too if such program exist. It would be nice if it could configured within Firefox (in runtime). I'd like to avoid IPTables solutions if possible.

  • 4
    this is also helpful for multiple internet connection with one doing torrent while other being used for surfing.
    – iamgopal
    Feb 11, 2011 at 12:53
  • You want to use different routes based on protocol/application, you will need iptables for that. Feb 11, 2011 at 13:59
  • 1
    I don't know how you can do this without something that maps your layer7 (application) traffic to a specific port or otherwise filters based on some higher level application info (which would require traffic inspection). So while iptables specifically isn't necessary, any solution involving a wrapper would have to interact with tcp or ip policy in some fashion. I don't know how to do this without a layer2 or layer3 networking that directs the traffic somewhere else.
    – belacqua
    Feb 11, 2011 at 16:03

4 Answers 4


What you are looking for is a LS_PRELOAD shim, see Daniel Lange's blog entry for a detailed explanation and example code.

  • 3
    Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Stormvirux
    Apr 12, 2014 at 15:09

You can use a more complex approach of connections marking and route policy.
It will work fine if you have a user that runs one software and anther.
This way you can mark the connections of one user and use specific routing table for it while all the others will use the default one.
The basic document to understand it all is at: http://www.lartc.org/lartc.html
Also an example for two connections you can see here: https://unix.stackexchange.com/questions/58635/iptables-set-mark-route-diferent-ports-through-different-interfaces
You can use the "owner" iptables module which will mark the connections to allow routing policy.

  • Policy routing works for different users, but not for an application running under one user (as described in OP). LD_PRELOAD seems the way to go (not for malicious programs / for security reasons), perhaps someone could elaborate Bob Lebins post?
    – Lekensteyn
    Sep 17, 2014 at 21:46

Here is a sample solution. It uses SOCKS server, setup on current machine to route coneections. Each application should be configured to use each server.

  • 3
    This looks like a HTTP proxy, does it work with other protocols, like a connection between two netcat instances?
    – Lekensteyn
    Mar 21, 2011 at 15:18

You can also use a VMware workstation machine to share different network interfaces which I do a lot to download from one interface and leave the other for my Netflix.

You do need to setup both ethX and wlanX on VMware but once you have it configured you're ready to download or browse.

It's pretty smooth. You can also use a firewall to bond interfaces which also works great.

  • While it works for this particular application, it unfortunately is not usable with other applications outside the VM such as Firefox.
    – Lekensteyn
    Sep 12, 2014 at 8:20

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.