vsftpd 是“very secure FTP daemon”的缩写,安全性是它的一个最大的特点。vsftpd 是一个 UNIX 类操作系统上运行的服务器的名字,它可以运行在诸如 Linux、BSD、Solaris、 HP-UNIX等系统上面,是一个完全免费的、开发源代码的ftp服务器软件。

一、问题现象
业务反馈,现网的一些主机通过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服务后,问题解决。
以上就是良许教程网为各位朋友分享的Linu系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你 !
