在 Debian 上部署的 FTPServer(通常是 vsftpd) 可以通过多种方式实现限速。下面按常见场景给你说明。
sudo apt update
sudo apt install vsftpd
编辑配置文件:
sudo nano /etc/vsftpd.conf
# 单位:字节/秒
local_max_rate=102400 # 100KB/s
anon_max_rate=51200 # 50KB/s(匿名用户)
说明:
local_max_rate:本地用户最大速度anon_max_rate:匿名用户最大速度user_config_dir1️⃣ 在配置文件中启用:
user_config_dir=/etc/vsftpd/user_conf
2️⃣ 创建目录:
sudo mkdir -p /etc/vsftpd/user_conf
3️⃣ 为指定用户创建配置文件:
sudo nano /etc/vsftpd/user_conf/username
内容示例:
local_max_rate=204800 # 200KB/s
✅ 每个用户可单独限速,非常灵活。
sudo apt install proftpd
编辑:
sudo nano /etc/proftpd/proftpd.conf
TransferRate RETR 100 # 100KB/s(下载)
TransferRate STOR 80 # 80KB/s(上传)
或针对用户:
<Limit RATE>
UserLimit username 100
</Limit>
sudo apt install trickle
启动 vsftpd(示例):
trickle -d 100 -u 80 vsftpd
⚠️ 不推荐用于生产环境,仅适合临时测试。
使用 tc(Traffic Control):
tc class add dev eth0 parent 1: classid 1:1 htb rate 1mbit
适合整台服务器或IP 限速,不是 FTP 专用。
| 场景 | 推荐方式 |
|---|---|
| 普通用户限速 | vsftpd + local_max_rate |
| 多用户不同限速 | vsftpd + user_config_dir |
| 临时限速测试 | trickle |
| 企业级流量控制 | tc / 网络设备 |
如果你愿意,可以告诉我:
我可以直接帮你写一份完整可用的配置文件。