远程客户端尝试连接到 CentoOS 中的 vsftpd,返回“连接被拒绝”

远程客户端尝试连接到 CentoOS 中的 vsftpd,返回“连接被拒绝”

我试图配置 ftp 服务在我的服务器上。一切似乎都已准备就绪,但客户端总是收到此响应:连接被拒绝

这是我的 iptables 文件的内容

# Generated by iptables-save v1.4.7 on Tue Jun  4 17:43:03 2013
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [3:412]
-A INPUT -p tcp -m tcp --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
-A OUTPUT -p tcp -m tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT
COMMIT
# Completed on Tue Jun  4 17:43:03 2013

如果你需要它,这就是iptables -L返回:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:mysql state NEW,ESTABLISHED 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http 
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
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 

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 spt:mysql state ESTABLISHED 

我很确定这与 iptables 有关,尽管我可能错了。我遵循了本教程。 有任何想法吗?

答案1

您需要将 ftp 的 ACCEPT 置于 REJECT all 之上。具体来说,这一行

-A INPUT -m state --state NEW -p tcp --dport 21 -j ACCEPT

需要超过这条线

-A INPUT -j REJECT --reject-with icmp-host-prohibited

/etc/syconfig/iptables按照您所遵循的文档在您的文件中。

相关内容