0

I have two internet connection, One internet connection has very high latency, it has fluctuation in connection (there is a tree between tower & Wifi CPE, so signal goes up & down) but its fine for downloading as connection never goes to 0. Another one is landline connection, they have strong download limit.

So what i want is to use wlan0 for few specific programs like, steam & downloading etc. basically program which consume lot of data.

And i want to use wlan1 for browsing & other stuffs, less data.

In short, I want to route specific programs though specific NIC, I don't have specific range of IP's.

I can connect both of them through wifi as i have 1 extra wifi adapter (wlan0,wlan1), as another option i can connect one with ethernet (wlan0,eth0)

2 Answers2

1

It could be possible if your process has something iptables can match against, such as a specific group. For example, given a group to-wifi, you could have iptables rules like so:

iptables -A FORWARD --in-interface wlan0 -j ACCEPT
iptables -t nat -A OUTPUT -m owner --gid-owner to-wifi --out-interface wlan0 -j MASQUERADE  

(And with forwarding enabled: sysctl -w net.ipv4.conf.all.forwarding=1.)

Then, if you run, for example, Steam thus:

sg to-wifi steam

Any traffic from that Steam process (+ any child processes) will be forwarded from whichever interface it was heading through to the wireless interface.

I have never tried interface-to-interface redirection, but I have used iptables to redirect all TCP traffic from Steam to a proxy by matching against groups, so these rules may not be enough by themselves.


This could be accomplished by creating groups for each interface and adding yourself to them. For example, using the addgroup and adduser commands:

sudo addgroup to-wifi
sudo adduser $USER to-wifi
sudo addgroup for-eth0
sudo adduser $USER for-eth0

You need to re-login for your new group memberships to take effect.

Related:

muru
  • 207,228
0

As far as I know, there is no way to do that.

This can be done with iptables rules on the specific ports + destinations they use to make their connections, but I'm not aware of a local way to do it.