我在配置vsftpd时遇到了问题。我已经设法使积极的FTPS工作良好,但被动是顽固的。我认为问题在于iptable如何管理端口。当我试图在filezilla上使用被动ftp时,所有内容都连接起来,但是目录清单在EHOSTUNREACH中失败了。以下是客户端与服务器之间的交换--设置被动模式
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 */下面是我用来设置输出规则的命令。输入一个非常相似,但我可以提供它,如果需要的话。
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。
我不知道,伊普塔莱可能根本不是问题。如果需要更多的信息,我当然可以给出。
编辑:
以下是客户端的iptable规则:
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 发布于 2017-06-08 09:02:38
您连接到的FTP服务器是否位于NAT路由器的另一端?我看到了192.168。在您的IP中,因此有一个专用网络涉及。您已经有了一个非常开放的iptable设置,所以我不认为这是问题所在(尽管您可以尝试刷新表,看看这是否有任何区别)。
被动FTP要求FTP服务器重新连接到FTP客户端(有关被动FTP的更详细说明,请参见此处),因此这种新的返回连接很可能无法通过NAT路由器返回。有一个用于IPTables的FTP模块,我认为它可以处理这个问题,但是如果涉及NAT,我只会使用活动FTP (或者其他评论--如果可能的话使用其他东西)。
您显示的IPTables是您的FTP客户端,而不是某种路由器,对吗?
发布于 2017-06-08 13:30:20
当ftp服务器的公共地址是应该配置的地址时,我已经看到了FTP服务器提供NAT地址的问题。这会导致被动连接的问题,因为客户端需要一个不同的地址。初始连接通常在该场景中工作,但被动模式不起作用。
看看您的vsftpd配置,或者随意分享它。
https://serverfault.com/questions/854534
复制相似问题