Centos7 firewalld防火墙

Centos7 firewalld防火墙

一、 Centos7和Centos6 防火墙的区别

使用的工具不一样了。Centos6 使用的是iptables,Centos7 使用的是filewall
iptables 用于过滤数据包,属于网络层防火墙。
firewall 能够允许哪些服务可用,那些端口可用...属于更高一层的防火墙。

二、常用命令:

systemctl enable firewalld.service
systemctl restart firewalld.service
firewall-cmd --state    查看状态
firewall-cmd --list-all   查看过滤的列表信息
firewall-cmd --zone=public --permanent --add-port=3306/tcp     添加一个协议为tcp的3306端口过滤
vim /etc/firewalld/zones/public.xml     <port protocol="tcp" port="3306"/>
systemctl restart firewalld.service

三、firewall 配置

firewalld的配置存储在各种XML文件中
在/usr/lib/firewalld和/etc/firewalld中
这允许极大的灵活性,因为文件可以被编辑、写入、备份、用作其他安装的模板等等。
注意:以下firewalld 的操作只有重启之后才有效:service firewalld restart
1.系统配置目录(/usr/lib/firewalld/services)
目录中存放定义好的网络服务和端口参数,系统参数,不能修改。
2.用户配置目录(/etc/firewalld/)
3.如何自定义添加端口
用户可以通过修改配置文件的方式添加端口,也可以通过命令的方式添加端口,注意:修改的内容会在/etc/firewalld/目录下的配置文件中体现。
3.1命令的方式添加端口:

firewall-cmd --zone=public --permanent --add-port=3306/tcp

参数介绍:
1、firwall-cmd:是Linux提供的操作firewall的一个工具;
2、--permanent:表示设置为持久;
3、--add-port:标识添加的端口;
另外,firewall中有Zone的概念,可以将具体的端口制定到具体的zone配置文件中。
 
原文地址:https://www.cnblogs.com/jidehuijia/p/14254879.html