温馨提示×

debian ftpserver如何限流

小樊
45
2026-10-12 15:27:31
栏目: 智能运维

在 Debian 上搭建 FTP 服务器(常见为 vsftpd 或 ProFTPD),限流(带宽限制)通常从 服务端配置 或 系统层(iptables / tc) 入手。下面按常见方案说明。


一、使用 vsftpd 限流(最常用)

1. 安装

sudo apt update
sudo apt install vsftpd

2. 限制匿名用户带宽

编辑 /etc/vsftpd.conf:

anon_max_rate=50000

表示匿名用户最大 50 KB/s。

3. 限制本地用户带宽

local_max_rate=100000

表示本地登录用户最大 100 KB/s。

4. 针对单个用户限流(推荐)

在 /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

✅ 优点:简单、稳定、无需额外工具
❌ 缺点:只能限制“总速率”,不能按连接数细分


二、使用 ProFTPD 限流

1. 安装

sudo apt install proftpd

2. 全局限速

编辑 /etc/proftpd/proftpd.conf:

TransferRate RETR 100
TransferRate STOR 100

单位:KB/s

3. 按用户限速

<Limit RATE>
  UserLimit test 50
</Limit>

重启:

sudo systemctl restart proftpd

三、系统层限流(iptables + tc,进阶)

适合 整体 FTP 流量限制(不区分用户)。

示例:限制 FTP 端口 21 入向 1Mbps

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

如果你能说明:

  • 使用的 FTP 软件(vsftpd / ProFTPD)
  • 限流对象(单用户 / 全部 / 上传或下载)
  • Debian 版本

我可以给你一份 可直接用的配置文件。

0 踩