VSFTP 无法通过 VPN 运行

VSFTP 无法通过 VPN 运行

我已经使用 vsftp 运行了一段时间的 FTP 服务,在被动模式下运行没有任何问题。

我最近使用 openvpn 设置了一个 VPN,据我所知,我已经正确配置了一切。我能够使用本地 IP 等连接到服务器(包括 FTP 服务器),并浏览互联网。

由于某种原因,我无法通过 VPN 使用 FTP,我可以连接并登录,但当客户端 (filezilla) 发布 LIST 时,它会卡住。我相信这是被动某个地方的问题,尽管我能够从网络内的其他服务器连接到 FTP(使用被动)。

有人之前遇到过这种情况吗?或者有人知道我可能遗漏了什么吗?

仅供参考,这是在使用 cent os 6.5 的 AWS VPC 中!

谢谢!

FTP 日志、欢迎消息、用户名和外部 IP 用#替换;

Thu Feb 19 17:03:24 2015 [pid 29762] CONNECT: Client "10.0.0.17"
Thu Feb 19 17:03:24 2015 [pid 29762] FTP response: Client "10.0.0.17", "220 Welcome to #############."
Thu Feb 19 17:03:24 2015 [pid 29762] FTP command: Client "10.0.0.17", "AUTH TLS"
Thu Feb 19 17:03:24 2015 [pid 29762] FTP response: Client "10.0.0.17", "530 Please login with USER and PASS."
Thu Feb 19 17:03:24 2015 [pid 29762] FTP command: Client "10.0.0.17", "AUTH SSL"
Thu Feb 19 17:03:24 2015 [pid 29762] FTP response: Client "10.0.0.17", "530 Please login with USER and PASS."
Thu Feb 19 17:03:24 2015 [pid 29762] FTP command: Client "10.0.0.17", "USER ##############"
Thu Feb 19 17:03:24 2015 [pid 29762] [##############] FTP response: Client "10.0.0.17", "331 Please specify the password."
Thu Feb 19 17:03:25 2015 [pid 29762] [##############] FTP command: Client "10.0.0.17", "PASS <password>"
Thu Feb 19 17:03:25 2015 [pid 29761] [##############] OK LOGIN: Client "10.0.0.17"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", "230 Login successful."
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP command: Client "10.0.0.17", "SYST"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", "215 UNIX Type: L8"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP command: Client "10.0.0.17", "FEAT"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", "211-Features:"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", " EPRT??"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", " EPSV??"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", " MDTM??"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", " PASV??"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", " REST STREAM??"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", " SIZE??"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", " TVFS??"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", " UTF8??"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", "211 End"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP command: Client "10.0.0.17", "OPTS UTF8 ON"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", "200 Always in UTF8 mode."
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP command: Client "10.0.0.17", "PWD"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", "257 "/""
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP command: Client "10.0.0.17", "TYPE I"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", "200 Switching to Binary mode."
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP command: Client "10.0.0.17", "PASV"
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", "227 Entering Passive Mode (#############)."
Thu Feb 19 17:03:25 2015 [pid 29766] [##############] FTP command: Client "10.0.0.17", "LIST"
Thu Feb 19 17:04:25 2015 [pid 29766] [##############] FTP response: Client "10.0.0.17", "425 Failed to establish connection."

答案1

在被动 FTP 模式下,服务器向客户端发送一个 IP 地址和客户端需要连接的端口,以打开数据传输连接(用于文件传输和目录列表)。

如果该 IP 地址与您实际需要用于连接服务器的 IP 地址不同(例如由于 NAT),则连接失败。

如果 NAT 发生在服务器端网络上,则应为 FTP 服务器配置其外部 IP 地址。

正如您所说的那样,NATing 发生在客户端网络上(如果我理解正确的话),更改不能在服务器端进行,因为这会破坏所有其他用户的 FTP 服务器。

智能 NAT 会尝试检查 FTP 流量并转换 IP 地址作为PASV响应。但如果 FTP 流量是加密的(TLS/SSL),那么这种方法就行不通了,我希望你的情况也是如此!

我知道的唯一替代解决方案是强制您的 FTP 客户端忽略PASV响应中的 IP 地址并使用用于连接到 FTP 服务器的原始 IP 地址。

例如,使用 WinSCP FTP/SFTP 客户端,您可以通过设置会话选项来实现强制使用被动模式连接的 IP 地址
https://winscp.net/eng/docs/ui_login_ftp

(我是 WinSCP 的作者)

另一个选择是使用支持更现代EPSV命令的 FTP 客户端(而不是PASV),因为它允许服务器仅提供端口(而不是 IP 地址),因此它不存在问题。 vsftpd 确实支持它。

有关详细信息,请参阅(我的)文章从网络配置角度看 FTP 被动模式

相关内容