[root@nginx01 zones]# cat public.xml Public 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. ##可以开放端口地址范围"10050-10051",不单只限定一个端口 ##放通指定ip,指定端口、协议 ##放通任意ip访问服务器的9527端口 firewall-cmd --reloadservice firewalld restart #使配置文件重新加载
方法2、命令行修改防火墙策略,仍需重启firewalld.service或重新加载防火墙配置文件
firwall-cmd --permanent --add-port=9527/tcp 插入防火墙规则,放通9527端口。success #命令执行成功同时,在/etc/firewall/zones/public.xml中自动生成该规则。 xx. xxx. service firewalld restartfirewall-cmd --reload #重启或重新加载配置文件,使配置生效 firewall-cmd --list-allfirewall-cmd --permanent --query-port=9527/tcp #查询刚插入的规则是否生效
cat /usr/lib/firewalld/services/ssh.xml SSH Secure Shell (SSH) is a protocol for logging into and executing commands on remote machines. It provides secure encrypted communications. If you plan on accessing your machine remotely via SSH over a firewalled interface, enable this option. You need the openssh-server package installed for this option to be useful. ##定义ssh.xml服务使用的协议,和通信的端口信息。
自定义服务(mongo.xml)模块cat /usr/lib/firewalld/services/mongo.xml mongo The service of mongo. 防火墙应用服务器模块cat /etc/firewalld/zones/mongo.xml mongo mongo service 查看mongo.xml服务的防火墙生效情况firewall-cmd --list-all-zones...mongo interfaces: sources: 2.2.2.2/24 services: mongo ports: masquerade: no forward-ports: icmp-blocks: rich rules:...
cat multi.xml multi services IP of 10.10.86.44 apply in multi srevices. ##同时添加多个服务 firewall-cmd --list-all-zones...multi interfaces: sources: 10.10.86.44 services: http mysql ssh ports: masquerade: no forward-ports: icmp-blocks: rich rules:...