Get the App
SLTechnology News&Howtos  ›  Servers  › 

What are the knowledge points of global bandwidth limit in PureFTPd

Shulou Source: shulou.com Published: 2022-06-01 00:52:07 09月20日 Update

The purpose of this article is to share with you what are the knowledge points about global bandwidth limits in PureFTPd. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

How to limit the total bandwidth consumed by FTP?

Pure-FTPd can limit the bandwidth consumed by each session. However, limiting the total bandwidth is a feature that is deliberately not added, because most operating systems already have effective algorithms to deal with bandwidth limitations.

Here is an example on Linux.

1) View / proc/sys/net/ipv4/ip_local_port_range file. You can see two numbers: this is the range of local ports that the Linux kernel uses to handle external connections. The FTP ports you want to reserve for passive mode FTP must not fall within this range. So, if:

"cat / proc/sys/net/ipv4/ip_local_port_range" returns "32768-61000", so you can reserve ports 10000 to 20000 for the FTP server instead of 30000-40000. Similarly, you can also choose to change the port range of the local area.

2) change the previous lines and save the following script.

#! / bin/sh

# simple bandwidth limitation-j@4u.net, the original author in English

# change the following data to your connection bandwidth

# (for waiting users, write down the * bandwidth you may get instead of the speed of the local Ethernet connection.)

REAL_BW='10Mbit'

# change the following data to the bandwidth you want to allocate to FTP

# the bandwidth we use is megabits, not megabytes, so 80Kbit is 10 Kilobytes/s

FTP_BW='80Kbit'

# change the following data to your physical device (or 'ppp0')

NIC='eth0'

# change the following data to the port range that you assigned to the passive FTP

FTP_PORT_LOW= "10000" FTP_PORT_HIGH= "20000" tc qdisc add dev "$NIC" root handle 1: cbq\ bandwidth "$REAL_BW" avpkt 1000 tc class add dev "$NIC" parent 1: classid 1:1 cbq bandwidth "$REAL_BW"\ rate "$REAL_BW" maxburst 5 avpkt 1000 tc class add dev "$NIC" parent 1:1 classid 1:10 cbq\ bandwidth "$REAL_BW" rate "$FTP_BW" maxburst 5 avpkt 1000 bounded tc qdisc add dev "$NIC" parent 1:10 sfq quantum 1514b tc filter add dev "$NIC" parent 1: protocol ip handle 1 fw flowid 1:10 iptables-t mangle-An OUTPUT-p tcp-sport 20:21-j MARK-- set-mark 1 iptables-t mangle-An OUTPUT-p tcp\-sport "$FTP_PORT_LOW": "$FTP_PORT_HIGH"-j MARK-set-mark 1

3) make sure you have installed the 'tc' command. If your distribution doesn't provide 'ip'' and 'tc'' commands, the script won't work. To use these commands, you need to install a package called 'iproute2'.

4) add your given passive port range and start Pure-FTPd.

/ usr/local/sbin/pure-ftpd-p 10000 20000-HBA

5) run the script created when you run the second step. If the script doesn't work, check that QOS support is compiled into your Linux kernel.

Thank you for reading! This is the end of this article on "what are the knowledge points of global bandwidth restrictions in PureFTPd". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Bandwidth limits ports ranges facets data scripts knowledge commands runs global knowledge points two content kernel that is time more articles if Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Redmi Shulou Tech Info Shulou Technology OPPO Reno