被动FTP无法正常工作

我一直在configurationvsftpd有问题。 我已经设法得到积极的FTPS工作正常,但被动是固执的。 我认为问题在于iptables如何pipe理端口。 当我尝试在filezilla上使用被动ftps时,所有东西都连接起来,但是目录列表失败, EHOSTUNREACH带有EHOSTUNREACH 。 这里是客户端和服务器之间build立被动模式的交换

 Command: PASV Response: 227 Entering Passive Mode (192,168,0,10,169,39). Command: LIST Error: The data connection could not be established: EHOSTUNREACH - No route to host 

这里是我的vsftpd.conf的相关部分:

 pasv_enable=YES pasv_min_port=40000 pasv_max_port=50000 

这是iptables -L的输出:

 Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT icmp -- anywhere anywhere ACCEPT all -- anywhere anywhere ACCEPT tcp -- anywhere anywhere ctstate NEW tcp dpt:ftp ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh REJECT all -- anywhere anywhere reject-with icmp-host-prohibited ACCEPT tcp -- anywhere anywhere tcp dpt:ftp ctstate NEW,ESTABLISHED /* Allow ftp connections on port 21 */ ACCEPT tcp -- anywhere anywhere tcp dpt:ftp-data ctstate RELATED,ESTABLISHED /* Allow ftp connections on port 20 */ ACCEPT tcp -- anywhere anywhere tcp spts:safetynetp:50000 dpts:safetynetp:50000 ctstate ESTABLISHED /* Allow passive ftp inbound connections */ Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:ftp ctstate NEW,ESTABLISHED /* Allow ftp connections on port 21 */ ACCEPT tcp -- anywhere anywhere tcp dpt:ftp-data ctstate ESTABLISHED /* Allow ftp connections on port 20 */ ACCEPT tcp -- anywhere anywhere tcp spts:safetynetp:50000 dpts:safetynetp:50000 ctstate RELATED,ESTABLISHED /* Allow passive ftp inbound connections */ 

这是我用来设置输出规则的命令。 input一个非常相似,但如果需要,我可以提供。

 iptables -A OUTPUT -p tcp -m tcp --sport 40000:50000 --dport 40000:50000 -m conntrack -- ctstate ESTABLISHED,RELATED -j ACCEPT -m comment --comment "Allow passive ftp inbound connections" 

我在被动iptables规则的safetynetp部分找不到任何有关信息,我认为问题是这与我设置的端口范围(40,000-50,000)相冲突,因为它看起来像是接受港口50,000。

iptables可能不是问题,我不知道。 如果需要更多的信息,我当然可以把它给出来。

编辑:

这里是客户端的iptables规则:

 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 

您正在连接到NAT路由器另一端的FTP服务器? 我看到192.168。 在你的IP那里有一个私人networking涉及。 你有一个非常开放的iptables设置,所以我不认为这是问题(尽pipe你可以尝试刷新表,看看是否有任何区别)。

被动FTP要求FTP服务器build立一个新的连接回到你的FTP客户端( 参见这里了解被动FTP的更详细的描述 ),所以这个新的返回连接很可能无法通过NAT路由器返回。 有一个FTP模块IPTables,我认为这是处理,但如果涉及到NAT,我只是使用主动FTP(或其他评论说 – 如果可能的话,完全使用其他的东西)。

你已经显示的IPTables是你的FTP客户端,而不是某种types的路由器,是正确的?

当FTP服务器的公共地址是应该configuration的那个时,我看到了ftp服务器发出NAT地址的问题。 这会导致被动连接的问题,因为客户端需要不同的地址。 初始连接通常在这种情况下工作,但被动模式不起作用。

看看你的vsftpdconfiguration,或者随意分享。