在 Debian 上搭建 FTP 服务器(常见为 vsftpd 或 ProFTPD),限流(带宽限制)通常从 服务端配置 或 系统层(iptables / tc) 入手。下面按常见方案说明。
sudo apt update
sudo apt install vsftpd
编辑 /etc/vsftpd.conf:
anon_max_rate=50000
表示匿名用户最大 50 KB/s。
local_max_rate=100000
表示本地登录用户最大 100 KB/s。
在 /etc/vsftpd.conf 中启用:
user_config_dir=/etc/vsftpd/user_conf
创建目录:
sudo mkdir -p /etc/vsftpd/user_conf
为用户 test 单独配置:
sudo nano /etc/vsftpd/user_conf/test
内容:
local_max_rate=20000
重启服务:
sudo systemctl restart vsftpd
✅ 优点:简单、稳定、无需额外工具
❌ 缺点:只能限制“总速率”,不能按连接数细分
sudo apt install proftpd
编辑 /etc/proftpd/proftpd.conf:
TransferRate RETR 100
TransferRate STOR 100
单位:KB/s
<Limit RATE>
UserLimit test 50
</Limit>
重启:
sudo systemctl restart proftpd
适合 整体 FTP 流量限制(不区分用户)。
sudo tc qdisc add dev eth0 root tbf rate 1mbit burst 32kbit latency 400ms
或使用 wondershaper:
sudo apt install wondershaper
sudo wondershaper eth0 1024 1024
| 场景 | 推荐方式 |
|---|---|
| 简单用户限速 | vsftpd + user_config |
| 多用户差异限速 | vsftpd 用户配置 |
| 整机 FTP 限流 | tc / wondershaper |
| 高并发专业场景 | ProFTPD |
如果你能说明:
我可以给你一份 可直接用的配置文件。