53

解决vsftpd连接变慢的情况

 5 years ago
source link: https://www.linuxprobe.com/vsftpd-soft-conn.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
一、问题现象

业务反馈,现网的一些主机通过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服务后,问题解决。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK