一、问题现象

业务反馈,现网的一些主机通过ftp连接时,经常会遇到超时情况,通过手动连接也发现正常响应后,后面认证时花很长时间才连上。查看vsftpd.conf配置没发现什么异常。

二、分析解决

先在本机通过连接回环地址,发现连接还是比较快的,没有出现卡顿情况,通过其他主机,连接本机的两个地址,发现都出现卡顿情况。换其他客户端连接,也是出现同样的情况 。这就出现了悖论 --------- 如果服务器端有问题,理论回环地址连也会出现卡的情况,如果客户端有问题,换了其他主机也有该情况,同时ping回包很快,而且直接连接的时候,出现输入用户名的界面也很快。让网络的同事抓了个包看了下:

通过查看包信息发现,认证过程中延迟在20s左右,这20s花在了哪里呢?

网上查询vsftpd连接慢的问题后,发现有人提出reverse_lookup_enable参数可能会出现较大的延迟。关于该数的man信息如下:

reverse_lookup_enable
Set to YES if you want vsftpd to transform the ip address into the hostname, before pam 
authentication. This is useful if you use pam_access including the hostname. If you want 
vsftpd to run on the environment where the reverse lookup for some hostname is available 
and the name server doesn’t respond for a while, you should set this to NO to avoid a 
performance issue.
Default: YES

既然默认是YES,而且是其会尝试反解析,这里就修改下,在/etc/vsftpd/vsftpd.conf文件中增加reverse_lookup_enable=NO,并重启vsftpd服务后,问题解决。

原文来自:http://www.361way.com/vsftpd-slow/5667.html

本文地址:https://www.linuxprobe.com/vsftpd-soft-conn.html编辑:张雄,审核员:逄增宝

本文原创地址:https://www.linuxprobe.com/vsftpd-soft-conn.html编辑:问题终结者,审核员:暂无