centos防火墙设置

centos在7.x以后,默认使用firewalld来管理防火墙,之前的iptables 默认不支持了

在centos7中执行service iptables start 报如下错误

Redirecting to /bin/systemctl status  iptables.service

解决办法:使用firewalld来管理防火墙,或者停用firewalld,重新安装iptables

这里还是使用iptables

执行如下命令:

##停用firewalld
systemctl stop firewalld
systemctl mask firewalld

##安装iptables
yum install iptables-services
systemctl enable iptables     ##开机自启动


systemctl stop iptables
systemctl start iptables
systemctl restart iptables
systemctl reload iptables

###这里不要使用service restart iptables的方式了,貌似不行了,就得使用systemctl 

开放8188端口

首先,查看iptables规则
iptables -L -n
vim /etc/sysconfig/iptables

这里原始22端口是开放的,所以我就直接复制了22的规则

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

然后执行:

systemctl stop iptables
systemctl start iptables
iptables -L -n

这时候,8188端口就开启了

这里只是记录一下,之后再系统的学习一下防火墙的知识

原文地址:https://www.cnblogs.com/goldenSky/p/11584067.html