Ubuntu – How to an application (like Firefox) be forced to use a certain network interface

firefoxnetworking

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.

Best Answer

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

Related Question