查看手册
man firewalld
配置文件
默认配置文件位于/usr/lib/firewalld
系统配置文件位于/etc/firewalld
服务文件
参考xml服务文件新增服务或为已有服务增加端口
例如smtp服务开启tcp 25端口
[root@localhost ~]# cat /usr/lib/firewalld/services/smtp.xml
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Mail (SMTP)</short>
<description>This option allows incoming SMTP mail delivery. If you need to allow remote hosts to connect directly to your machine to deliver mail, enable this option. You do not need to enable this if you collect your mail from your ISP's server by POP3 or IMAP, or if you use a tool such as fetchmail. Note that an improperly configured SMTP server can allow remote machines to use your server to send spam.</description>
<port protocol="tcp" port="25"/>
</service>
[root@localhost ~]#
为区增加服务
临时增加
firewall-cmd --zone=public --add-service=smtp
永久增加
firewall-cmd --permanent --zone=public --add-service=smtp
查看
查看区上的服务
firewall-cmd --list-all-zones
查看防火墙开放的端口
iptables -L -n
可以看到在IN_ZONE_public_allow区中允许了tcp 25端口