如果某个连接请求没有划分到任何一个zone,那么就会走默认的zone,Centos7 默认情况下,默认zone为public 。可以通过以下命令查看或者修改默认zone 。
1-2-5 获取默认的zone:
firewall-cmd --get-default-zone1-2-6 修改默认的zone:
firewall-cmd --permanent --set-default-zone=[zone]1-2-7 其他的一些相关的命令:
列出该zone下绑定了哪些interface:firewall-cmd [--zone=zone] --list-interfaces将该interface绑定到另一个zone上:firewall-cmd [--permanent] [--zone=zone] --change-interface=interface如果该interface之前绑定到了某个zone,则取消绑定,这样就会走默认zonefirewall-cmd [--permanent] --remove-interface=interface与source相关的:firewall-cmd [--permanent] --remove-source=sourcefirewall-cmd [--permanent] [--zone=zone] --list-sourcesfirewall-cmd [--permanent] [--zone=zone] --add-source=source01-2
zone的配置文件
一个zone的xml配置文件的示例如下:
<?xml version="1.0" encoding="utf-8"?><zone target="DEFAULT"><short>Public</short><description>For use in public areas. You do not trust the other computers on.NETworks to not harm your computer. Only selected incoming connections are accepted.</description><service name="ssh"/><service name="dhcpv6-client"/><port protocol="tcp" port="80"/><port protocol="tcp" port="8080"/><source address="192.168.5.112"><source address="10.12.18.0/24"/><rule family="ipv4"><source address="10.12.18.0/24"/><port protocol="tcp" port="7180-7190"/><accept/></rule></zone>每个标签的含义:
zone:给一个zone指定target,
target=“ACCEPT|%%REJECT%%|DROP”可用于接受(ACCEPT)、拒绝(%%REJECT%%)或丢弃(DROP)与任何规则(端口、服务等)都不匹配的每个数据包,即指定该zone的默认的对连接(connection)、网口(interface)或源地址(source address)的行为,如果不指定target,则默认为default,default的行为与REJECT类似 。
short:给该zone指定一个名字 。
description:对该zone的描述
service:该zone开启的服务(service),service下一小节会讲 port:该zone打开的端口,protocol属性可以指定协议,通常为tcp或udp,port属性指定端口号
source:绑定到该zone的source,其效果等同于 firewall-cmd [–permanent] [–zone=zone] --add-source=source 指令
rule:为该zone添加的富语言规则(rich language rule) 。
rich language rule的写法可以参照官网https://firewalld.org/documentation/man-pages/firewalld.richlanguage
上述示例的富语言规则的含义为对10.12.18.X网段的source开放7180至7190所有端口的tcp连接请求 。
【Centos7防火墙配置详解】对于service的理解
02、Service的概念
service是预定义的一系列的本机的协议、端口、目标ip等,service可以让我们更加方便的让防火墙限制外部对本机的某些端口的访问 。service的配置文件在/etc/firewalld/services或
/usr/lib/firewalld/services文件夹下,每个service的配置都是一个xml文件 。
02-1
service配置文件
系统在
/usr/lib/firewalld/services文件夹下为我们预定义了一些列的service配置文件,我们也可以在/etc/firewalld/services定义自己的service 。例如,ftp.xml的内容如下:
<?xml version="1.0" encoding="utf-8"?><service><short>FTP</short><description>FTP is a protocol used for remote file transfer. If you plan to make your FTP server publicly available, enable this option. You need the vsftpd package installed for this option to be useful.</description><port protocol="tcp" port="21"/><module name="nf_conntrack_ftp"/></service>这样,在某个zone的配置文件中可以引用这个service,例如,在public.xml中引入ftp service:<?xml version="1.0" encoding="utf-8"?><zone><short>Public</short><description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description><service name="dhcpv6-client"/><service name="ssh"/><service name="ftp"/></zone>等价于:<?xml version="1.0" encoding="utf-8"?><zone><short>Public</short><description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description><service name="dhcpv6-client"/><service name="ssh"/><port protocol="tcp" port="21"/></zone>
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 东风标致4008配置参数 4008标致
- 电脑配置怎么看显卡配置 电脑配置怎么看显卡
- 在哪里看自己电脑的配置 怎么查看电脑配置信息
- Linux下网络共享存储搭建与配置
- h3c交换机配置ip~~如何初始化配置H3C交换机?
- 古墓丽影9劳拉mod 古墓丽影9配置
- 2020年电脑主流配置 电脑配置怎么看
- 联想b470e配置参数__联想b470笔记本电脑支持多大的内存的
- qq登陆超时请检查您的网络和防火墙设置00001?qq登录超时是怎么回事?
- 华为p10参数配置详细-华为p10具体尺寸是多少
