CentOS6.8防火墙放行端口

Posted mahoshojo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS6.8防火墙放行端口相关的知识,希望对你有一定的参考价值。

编辑iptables

vi /etc/sysconfig/iptables

iptables的内容一般是这样的

# Generated by iptables-save v1.4.7 on Sat Dec  7 17:28:22 2019
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1:152]
:syn-flood - [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
COMMIT
# Completed on Sat Dec  7 17:28:22 2019

添加放行端口

-A INPUT -p tcp -m state --state NEW -m tcp --dport 端口号 -j ACCEPT

重启防火墙

service iptables restart

查看防火墙状态

service iptables status

以上是关于CentOS6.8防火墙放行端口的主要内容,如果未能解决你的问题,请参考以下文章