centos7 关闭默认firewalld,开启iptables

编者按:

  对于使用了centos6系列系统N年的运维来说,在使用centos7的时候难免会遇到各种不适应。比如防火墙问题。本文主要记录怎么关闭默认的firewalld防火墙,重新启用iptables。

1.关闭firewalld防火墙

systemctl stop firewalld
systemctl mask firewalld

2.安装iptables

yum install iptables-services

3.设置开机启动

systemctl enable iptables.service
systemctl [stop|start|restart] iptables。service
#or
service iptables [stop|start|restart]

注意:

在启动的时候会遇到这样的问题:Unit iptables.service failed to load
问题根源是在/etc/sysconfig/下面没有找到iptables文件。解决办法如下:
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
/usr/libexec/iptables/iptables.init save #保存成功
然后再执行
systemctl start iptables.service

  

  

  

  

原文地址:https://www.cnblogs.com/songqingbo/p/6829797.html