我正在使用 ubuntu 14.04 和 vsftpd 版本 3.0.2,我的问题与通过 FTP 上传文件有关。这项服务在过去两年中运行良好,我能够上传数千个文件,且没有任何错误。但是最近,我再也无法做到这一点了,如果我尝试上传 1000 个文件,它会成功上传前 ~300 个文件,但随后它会开始失败,直到逐渐所有上传槽都被阻止,对这些失败的文件重试 2 次,等待超时,最后我留下一堆失败的传输。
我在 Windows 上使用 Filezilla 3.33 作为客户端。Filezilla 最初出现故障时的样子如下:
Status: Starting upload of C:\wamp64\www\system\themes\widget\html.php
Status: Retrieving directory listing of "/web/domain.com/public_html/system/themes/widget"...
Command: PASV
Response: 227 Entering Passive Mode (10,10,20,10,50,217).
Command: STOR icon_box.php
Response: 150 Ok to send data.
Error: Connection timed out after 10 seconds of inactivity
Error: File transfer failed
对于失败的传输,vsftp.log 如下所示:
Sat Jun 2 10:17:00 2018 [pid 29163] [admin] FAIL UPLOAD: Client "ip", "/web/domain.com/public_html/system/themes/widget/html.php", 853 bytes, 0.00Kbyte/sec
重试几次后,Filezilla 显示以下错误:
Response: 421 There are too many connections from your internet address.
Error: Could not connect to server
Status: Disconnected from server
Status: Delaying connection for 5 seconds due to previously failed connection attempt...
Response: 421 There are too many connections from your internet address.
Error: Could not connect to server
Response: 421 There are too many connections from your internet address.
Error: Could not connect to server
经过所有这些重试后,vsftp.log 现在看起来像这样:
Sat Jun 2 11:20:19 2018 [pid 3616] CONNECT: Client "ip", "Connection refused: too many sessions for this address."
Sat Jun 2 11:20:24 2018 [pid 3622] CONNECT: Client "ip", "Connection refused: too many sessions for this address."
Sat Jun 2 11:20:24 2018 [pid 3632] CONNECT: Client "ip", "Connection refused: too many sessions for this address."
我的 /etc/vsftpd.conf 如下所示:
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=002
anon_upload_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
dual_log_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
chroot_local_user=YES
listen=YES
pam_service_name=vsftpd
userlist_enable=NO
tcp_wrappers=YES
force_dot_files=YES
ascii_upload_enable=YES
ascii_download_enable=YES
#allow_writable_chroot=YES
allow_writeable_chroot=YES
seccomp_sandbox=NO
pasv_enable=YES
pasv_max_port=14000
pasv_min_port=12000
netstat -napt | grep 客户端IP
tcp 0 0 server_ip:21 client_ip:54986 TIME_WAIT -
tcp 1 0 server_ip:21 client_ip:54648 CLOSE_WAIT 4632/vsftpd
tcp 0 0 server_ip:12533 client_ip:54757 ESTABLISHED 4702/vsftpd
tcp 1 0 server_ip:21 client_ip:54730 CLOSE_WAIT 4698/vsftpd
tcp 0 0 server_ip:12342 client_ip:54900 ESTABLISHED 4700/vsftpd
tcp 0 0 server_ip:12113 client_ip:54854 TIME_WAIT -
tcp 0 0 server_ip:21 client_ip:54994 TIME_WAIT -
tcp 0 0 server_ip:13151 client_ip:54852 TIME_WAIT -
tcp 2122 0 server_ip:13772 client_ip:54690 CLOSE_WAIT -
tcp 0 0 server_ip:22 client_ip:54382 ESTABLISHED 4294/0
tcp 6001 0 server_ip:12738 client_ip:54679 CLOSE_WAIT -
tcp 2122 0 server_ip:13316 client_ip:54658 CLOSE_WAIT -
tcp 0 0 server_ip:12107 client_ip:54846 ESTABLISHED
这段代码总共有 180 行,而整个情况就是 Filezilla 说的响应:421 您的互联网地址的连接数过多。
答案1
答案2
首先要确认运行方式,使用chkconfig -A|grep vsftpd
,如果无效,要检查配置vi /etc/xinetd.d/vsftpd
,disable = no
表示xinetd方式,disable = yes
表示独立方式。
如果您采用独立方法,则可以更改max_per_ip
为/etc/vsftpd.conf
扩展一个 IP 的会话。