CentOS – 允许通过IPtables访问FTP

对不起,这个愚蠢的问题,但我不能从CentOS 6.5浏览器打开我的FTP(ProFTPd)。 当我停止IPtables,我没有问题,但是当我正在运行。

端口21是开放的,端口20不是(我不知道如何打开它)。

编辑1:

从“iptables -L -n”

Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:21 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8000 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) target prot opt source destination 

编辑2:@HBruijn他的方式为我工作。

你的问题不是很好,但你描述的症状表明被动的FTP不能正确地与你的防火墙结合使用。

通常, insmod nf_conntrack_ftp命令足以将FTP辅助程序模块加载到configuration错误的RHEL6或CentOS防火墙中。

为了做到这一点:

编辑configuration文件/etc/sysconfig/iptables-config并将辅助模块nf_conntrack_ftp添加到IPTABLES_MODULESvariables中:

 IPTABLES_MODULES="nf_conntrack_ftp" 

或将其添加到其中已列出的任何其他模块。

您可以直接编辑iptablesconfiguration文件/etc/sysconfig/iptables然后重新启动iptables服务。 或者修改然后保存正在运行的configuration。 作为root或者sudo:

 # If using a custom chain for this sort of thing, APPEND port to chain: iptables -A MYCHAIN -m state --state NEW -p tcp --dport 20 -j ACCEPT service iptables save 

如果在INPUT链中有一个REJECT行,那么您需要确保添加到防火墙的端口在REJECT之前插入:

 # List the Chain with line numbers iptables -L INPUT -n --line-numbers # in this example 7 is REJECT line from the above, this will push the REJECT line down # and insert this right above it: iptables -I INPUT 7 -m state --state NEW -p tcp --dport 20 -j ACCEPT service iptables save 

如果需要,也不要忘记为ip6tables做同样的事情。