Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
4  
this is also helpful for multiple internet connection with one doing torrent while other being used for surfing. –  iamgopal Feb 11 '11 at 12:53
    
You want to use different routes based on protocol/application, you will need iptables for that. –  João Pinto Feb 11 '11 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. –  belacq Feb 11 '11 at 16:03

5 Answers 5

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: http://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.

share|improve this answer
    
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 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.

share|improve this answer
3  
This looks like a HTTP proxy, does it work with other protocols, like a connection between two netcat instances? –  Lekensteyn Mar 21 '11 at 15:18

I've done something similar when programming and testing complex or restrictive firewalls. For browsing other other tasks I use a virtual machine, bridging the networking onto one interface with the default gateway on my host machine being on the other.

This is a pretty heavy handed workaround, but for some circumstances this is helpful. Obviously if want to share data between the two quickly it doesn't work.

share|improve this answer

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

share|improve this answer
2  
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 at 15:09

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.

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

Your Answer

 
discard

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.