I'm running torrent client on my headless Ubuntu server. Also number of computers are connected to this server, which is used as internet gateway/router. The question is whether it's possible to configure iptables to prioritize traffic from eth1(lan if) over local traffic generated by server? Something like QOS..
There are several alternatives to achieve what you are looking for. But first of all, yes it is possible. Though, many of the possibilities are rather complex.
One of the easiest options might be to run the torrent daemon under a own user\group. Then use iptables to mark all traffic from that user\group with a flag. Then later let the tc filter on that flag and put it in the low priority queue. Look at the bottom of this wiki for an idea.
For what you are asking do you only need two queues(fig 1.), one low priority and one high. Though it might be better to stick with something closer to this example. You can adopt the example to your needs, just drop the part with nat and make the default mark lower value than the mark you will use for the traffic generated by the daemon.
So for my suggestion you can use something like
An alternative for setting a flag might be to use
The best might be to have a leaf for every fw mark. But my best advice now is, read and try to understand the example referred above to adopt it to your needs. If you have any questions add them.
In the example referred above, is it important that you understand this part (fig 2.) when you want to write iptables rules for marking or classifying traffic. For a short explanation of it with a slightly different looking diagram have a look at this.
This will point you in the right direction:
Quality of service is quite a complex topic -- the link posted by @anders-f-u-kiaer is possibly the best solution, but quite complex. I am not at all an expert on this so I will not comment.
Nevertheless, often a simpler solution can be handy. If you want just to limit the bandwidth for one program (for example, the torrent client) a much simple solution is using
You can install it by
and then you run a program with
(1) This is different from proper QoS: the bandwidth used by the "crippled" program will be reduced every time, not only when there is demand on the higher priority services as it will happen with proper QoS.
You don't do this with iptables. You need to change the routing metrics.
To give all other interfaces a higher priority than wlan0 simply run:
To reset the metrics of the routes attached to wlan0 simply run:
more info here: http://0pointer.de/lennart/projects/ifmetric/
protected by fossfreedom♦ Jan 9 '14 at 22:39
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?