提升 Linux 下 FTP 传输速度,可以从网络、系统、FTP 服务配置、客户端参数等多个方面入手。下面按常见场景给你一套实用优化方案。
先判断是 网络、磁盘、CPU 还是 FTP 本身:
# 查看实时网络
iftop
# 查看磁盘 IO
iostat -x 1
# 查看 CPU
top
被动模式(PASV)通常比主动模式快且稳定。
pasv_enable=YES
pasv_min_port=30000
pasv_max_port=31000
防火墙放行端口:
firewall-cmd --add-port=30000-31000/tcp --permanent
firewall-cmd --reload
DNS 解析会明显拖慢连接速度。
reverse_lookup_enable=NO
max_clients=200
max_per_ip=10
ls_recurse_enable=NO
ascii_upload_enable=NO
ascii_download_enable=NO
✅ 二进制模式(默认)
binary
❌ 避免 ASCII 模式(文本模式)
编辑 /etc/sysctl.conf:
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
生效:
sysctl -p
ext4 / xfsFTP 本身不支持多线程,但可用工具:
✅ lftp(强烈推荐)
lftp ftp://user:pass@host
mirror -c --parallel=10 /remote /local
✅ wget(单线程)
wget -c ftp://host/file
lftp 示例:
set net:socket-buffer 1048576
(仅内网)
ip link set eth0 mtu 9000
| 协议 | 速度 | 安全性 |
|---|---|---|
| FTP | 中 | 差 |
| SFTP | 高 | 好 |
| HTTP/HTTPS | 高 | 好 |
| rsync | 极高 | 好 |
示例:
rsync -avz --progress /local/ user@host:/remote/
如果你愿意,可以告诉我:
我可以给你一套针对你环境的精确优化方案。