在 Debian + vsftpd 中限制 FTP 传输速度,主要通过 vsftpd 的限速参数 来实现。下面按常见需求说明。
编辑 vsftpd 配置文件:
sudo nano /etc/vsftpd.conf
anon_max_rate=50000
表示 50 KB/s(单位是 字节/秒)
local_max_rate=100000
表示 100 KB/s
vsftpd 不支持在配置文件中按用户写不同速率,但可以通过 用户配置文件 实现。
user_config_dir1️⃣ 在配置文件中启用:
user_config_dir=/etc/vsftpd/user_conf
2️⃣ 创建目录:
sudo mkdir -p /etc/vsftpd/user_conf
3️⃣ 为每个用户创建配置文件(文件名 = 用户名)
例如限制用户 ftpuser1 为 200KB/s:
sudo nano /etc/vsftpd/user_conf/ftpuser1
内容:
local_max_rate=204800
⚠️ vsftpd 速率单位是 字节/秒(Byte/s)
换算示例:
| 限速 | 配置值 |
|---|---|
| 50 KB/s | 51200 |
| 100 KB/s | 102400 |
| 1 MB/s | 1048576 |
| 10 MB/s | 10485760 |
虽然不是限速,但常一起使用:
max_clients=50
max_per_ip=2
修改完成后重启 vsftpd:
sudo systemctl restart vsftpd
sudo tail -f /var/log/vsftpd.log
anon_max_rate 对 本地用户无效local_max_rate 对 匿名用户无效user_config_diranonymous_enable=NO
local_enable=YES
write_enable=YES
local_max_rate=512000
user_config_dir=/etc/vsftpd/user_conf
max_clients=50
max_per_ip=2
如果你愿意,可以告诉我:
我可以帮你直接生成一份 完整可用的 vsftpd.conf。