CentOS 7 部署iptables CentOS 7  默认的防火墙是firewall


关闭firewall使用iptables:

关闭firewall:

[root@localhost ~]# systemctl stop firewalld.service            //停止firewall
[root@localhost ~]# systemctl disable firewalld.service        //禁止firewall开机启动

安装iptables:

[root@localhost ~]# yum -y install iptables-services          //注意是services

开启iptables:

[root@localhost ~]# systemctl restart iptables.service                  //最后重启防火墙使配置生效
[root@localhost ~]# systemctl enable iptables.service                  //设置防火墙开机启动

保存规则:

[root@localhost ~]# service iptables save                              //第一种方法
[root@localhost ~]# iptables-save > /etc/sysconfig/iptables            //第二种方法