Linux CentOS 防火墙开放了指定端口, 为什么还是访问不了

防火墙规则如下

# Generated by iptables-save v1.4.7 on Tue Aug 20 10:09:45 2019
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [19:1438]
-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 -p tcp -m tcp --dport 20001 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Tue Aug 20 10:09:45 2019

注意这一行-A INPUT -j REJECT --reject-with icmp-host-prohibited,如果我们添加的规则在这行之下那么就不会生效

解决办法:在-A INPUT -j REJECT --reject-with icmp-host-prohibited之前加入我们的规则即可

转载于:https://my.oschina.net/kdy1994/blog/3094870

你可能感兴趣的:(Linux CentOS 防火墙开放了指定端口, 为什么还是访问不了)