Pure-Ftpd-Mysql:无法连接被动 FTP

Pure-Ftpd-Mysql:无法连接被动 FTP

看来我有一个配置问题,需要帮助。

我有一个网络服务器,在 Debian Jessie 下安装(并更新)了 pure-ftpd-mysql。

当服务器处于主动模式时,我可以通过 FTP 连接到服务器,但是当我要求以被动模式传递时,操作超时了:

ftp ftp.***.com
Connected to ftp.***.com.
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 12:31. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (ftp.***.com:tilotiti): 
331 User tilotiti OK. Password required
Password: 
230 OK. Current restricted directory is /
ftp> ls
200 PORT command successful
150 Connecting to port 50405
drwxr-xr-x    2 2001       ftp              4096 Dec 21 11:12 test1
drwxrwxrwx    2 2001       ftp              4096 Apr 28  2017 test2
226-Options: -l 
226 2 matches total
ftp> passive
Passive mode on.
ftp> ls
227 Entering Passive Mode (10,3,98,75,127,233)
ftp: connect: Operation timed out
ftp> 

我在 scaleway 上托管,我检查了那里没有配置为网络防火墙的规则。

我尝试通过创建文件 /etc/pure-ftpd/conf/PassivePortRange 来配置一些被动范围端口:

30000 50000

我已经检查过我的服务器防火墙没有阻止该连接:

$ iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

我重新启动了服务器以确保新的配置已被采用。

但它不起作用,我现在完全迷路了。我需要这种被动连接。

有人能帮助我吗?

非常感谢。

答案1

227 Entering Passive Mode (10,3,98,75,127,233)

意味着服务器正在等待到 10.3.98.75 端口 32745 的传入连接。当然,这是因为服务器是 NATed 并且(ftp 服务器)对此不知道。

您仍然需要做以下三件事中的两件:

  • 设置 FTP 服务器,使其“发布”已知的公共 IP,而不是其私有 IP。这是从pure-ftpd 文档

    - '-P <ip address or host name>': Force the specified IP address in reply to a PASV/EPSV/SPSV command. If the server is behind a masquerading (NAT) box that doesn't properly handle stateful FTP masquerading, put the ip address of that box here. If you have a dynamic IP addBindress, you can put the public host name of your gateway, that will be resolved every time a new client will connect.

Debian(?) 包装器配置似乎是ForcePassiveIP <ip address or host name>

  • /proc/sys/net/ipv4/ip_local_port_range将其设置为仅使用特定范围的端口(已完成,您选择了 30000:50000)。应选择不与动态端口范围重叠的范围以提高安全性。
  • 更改 Scaleway 的防火墙/nat 设置,以允许在上一步中对 TCP 端口范围进行端口转发(这就是我上面提到的安全性可能很重要的地方)。抱歉,我不知道在哪里可以找到有关此问题的具体文档。我甚至不明白 Scaleway 提供哪种网络配置。如果主机实际上有两个 IP,其中一个是 10.3.98.75,另一个是公共 IP,那么无需使用ForcePassiveIPBind选项 ( => -S) 就足够了。

相关内容