在 CentOS 上搭建 FTP 服务器并做限速设置,常见方案有 vsftpd(最常用)和 ProFTPD。下面以 vsftpd 为主说明,并补充 ProFTPD 的方式。
yum install vsftpd -y
systemctl enable vsftpd
systemctl start vsftpd
vsftpd 支持按用户限速,单位都是 字节/秒(B/s):
| 参数 | 作用 |
|---|---|
anon_max_rate |
匿名用户最大速度 |
local_max_rate |
本地用户最大速度 |
编辑配置文件:
vi /etc/vsftpd/vsftpd.conf
示例(限制为 1MB/s):
local_max_rate=1048576
anon_max_rate=524288
重启服务:
systemctl restart vsftpd
方式一:使用用户配置文件目录
mkdir -p /etc/vsftpd/user_conf
编辑 vsftpd.conf:
user_config_dir=/etc/vsftpd/user_conf
为用户 testuser 单独限速:
vi /etc/vsftpd/user_conf/testuser
内容:
local_max_rate=2097152
重启:
systemctl restart vsftpd
客户端使用 ftp 或 lftp 下载,观察速度是否受限。
yum install proftpd -y
编辑:
vi /etc/proftpd.conf
示例:
<Limit RATE>
RateLimit 1024 user *
</Limit>
或针对单个用户:
<IfUser testuser>
RateLimit 2048
</IfUser>
重启:
systemctl restart proftpd
✅ 限速单位:
✅ 防火墙:
firewall-cmd --add-service=ftp --permanent
firewall-cmd --reload
✅ SELinux(如遇问题):
setsebool -P ftpd_full_access on
如果你能告诉我:
我可以给你更精确的配置示例。