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.
What you are looking for is a LS_PRELOAD shim, see Daniel Lange's blog entry for a detailed explanation and example code.
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.
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.
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.