Limit global maximum number of connection by port number

I want to limit maximum number of connection by port because torrents left nothing to use. I have only 1 port to open for torrents so if I can limit connection router spare some cpu time to other jobs but I couldn't find how to do that anywhere. If anyone can help me Thank you in advance :slight_smile:

Connections do not use CPU time.
net.netfilter.nf_conntrack_max counts connection states in firewall including NAT
fs.file-max counts files system can open including connection sockets.

1 Like

I don't get it what you are saying. I am looking into firewall settings but don't see anything about it?

You have to determine which limit is in play and adjust respective sysctl.

As I reduce max connection limit in torrent client it also reduce cpu usage ( which actually used by softirq) but I want this setting in the router so I don't have to bother set every torrent client. :slight_smile:

You might want to apply this patch (edit 2 lines in file turning ?ifname into ?if):

You need to examine kernel log via luci or dmesg, whether it says out of file handles or conntrack table and adjust respective sysctl based on indication.

in the "root/usr/share/firewall4/templates/ruleset.uc" file just need to remove name part from iifname and thats it?

1 Like

Yes, and fw4 check and service firewall restart.
Thats for torrent on router itself.

The file is in /usr/share/.... not /root/.... just in case.

Regarding limits - you can limit open files per process NOT RUNNING AS ROOT, but there is no chance for connections, you need to increas conntrack so everyone fits.