centos 7如何使用firewalld 添加策略
发布日期:2025-03-31 00:55:05 浏览次数:11 分类:精选文章

本文共 861 字,大约阅读时间需要 2 分钟。

firewalld配置指南

启动firewalld

在Linux系统中,firewalld是默认的防火墙管理工具。若需启动firewalld服务,可使用以下命令:

systemctl start firewalld

启动后可查看服务状态,确认是否正常运行:

systemctl status firewalld
或者
firewall-cmd --state

停止firewalld

当不需要firewalld服务时,可以执行以下命令永久禁用服务,并立即停止运行:

systemctl stop firewalld
systemctl disable firewalld

firewalld配置文件修改

为了实现特定网络行为,firewalld使用XML配置文件进行规则定义。以下是public.xml的示例配置,位于/etc/firewalld/zones/目录下:

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.

所需服务和端口

根据你的实际需求,在Public区域内添加需要管理的服务和端口。例如:

这些配置指令将决定火墙对进入和出站网络连接的情况。

配置完成后操作

执行完上述配置后,测试firewalld服务状态,以确保配置生效:

systemctl status firewalld

如需修改配置,重新加载firewalld以应用更改:

firewall-cmd --reload

注意事项

本文内容最初来源:https://blog.51cto.com/fengxz/1948921

转载请注明原文出处。

上一篇:CentOS 7升级Python到3.5后yum出错
下一篇:centos 7 静态IP,指定DNS

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年05月08日 14时11分07秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章