firewalld/firewalld

GitHub: firewalld/firewalld

firewalld 是一个支持 D-Bus 接口的状态防火墙守护进程,提供基于区域的动态 IPv4、IPv6 及以太网桥规则管理。

Stars: 1019 | Forks: 295

[![Build status](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/9fba464987160340.svg)](https://github.com/firewalld/firewalld/actions/workflows/testsuite.yml?query=event%3Apush+workflow%3Atestsuite) [![Integration status](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/f8fd3ee47e160341.svg)](https://github.com/firewalld/firewalld/actions?query=event%3Apush+workflow%3Aintegration-testsuite) [![Source status](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/d778665ef5160342.svg)](https://github.com/firewalld/firewalld/actions?query=event%3Apush+workflow%3Asource-checks) # FirewallD - 一个带 D-Bus 接口且提供动态防火墙功能的守护进程 firewalld 提供了一个动态管理的防火墙,支持网络或防火墙区域来定义网络连接或接口的信任级别。 它支持 IPv4、IPv6 防火墙设置以及以太网网桥,并实现了运行时和永久配置选项的分离。它还提供了一个接口,供服务或应用程序直接添加 ip*tables 和 ebtables 规则。 ## 开发 要检出源代码仓库,您可以使用: ``` git clone https://github.com/firewalld/firewalld.git ``` 这将在本地创建该仓库的副本。 贡献者行为准则可以在 [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) 中找到 ## 语言翻译 Firewalld 使用 GNU gettext 进行本地化支持。可以使用 [Fedora 的 Weblate 实例][1] 进行翻译。翻译会定期合并到主 firewalld 仓库中。 ## 依赖项 以下是运行时依赖项: ``` linux >= 5.3 python >= 3.8 python3-dbus python3-gobject python3-nftables >= 0.9.4 ``` **注意**:不支持 python2。 ## 可选依赖项 这些依赖项可能会增强 firewalld 的功能,但它们并非必需。 ``` ebtables ipset iptables polkit python3-capng (libcap-ng-python3) ``` ## 使用源代码仓库 除了运行时依赖项之外,从源代码构建还需要一些其他依赖项: ``` desktop-file-utils: /usr/bin/desktop-file-install gettext intltool glib2: /usr/bin/glib-compile-schemas glib2-devel: /usr/share/aclocal/gsettings.m4 systemd-units pytest ``` 为了能够从 docbook 文件创建 man 页面和文档: ``` docbook-style-xsl libxslt ``` 使用通常的 autoconf/automake 命令来生成 makefiles ``` ./autogen.sh ./configure ``` 您可以通过传递 PYTHON 变量来使用特定的 Python 解释器。这也被测试套件所使用。 ``` ./configure PYTHON=/path/to/python3 ``` 使用 ``` make ``` 来创建文档并更新 po 文件。 使用 ``` make check ``` 来运行测试套件。测试在网络命名空间内运行,不会干扰主机上正在运行的 firewalld。也可以通过向 autotest 传递标志来并行运行它们。 ``` make check TESTSUITEFLAGS="-j4" ``` 测试套件还使用关键字来允许运行测试特定区域的子集。 例如: ``` make check TESTSUITEFLAGS="-k rich -j4" ``` 输出: ``` 24: rich rules audit ok 25: rich rules priority ok 26: rich rules bad ok 53: rich rules audit ok 23: rich rules good ok 55: rich rules bad ok 74: remove forward-port after reload ok ``` 您可以获取测试和关键字的列表 ``` make -C src/tests check TESTSUITEFLAGS="-l" ``` 或者仅获取关键字 ``` make -C src/tests check TESTSUITEFLAGS="-l" \ |awk '/^[[:space:]]*[[:digit:]]+/{getline; print $0}' \ |tr ' ' '\n' |sort |uniq ``` 还有集成测试。目前这包括 NetworkManager。这些可能会对主机造成 _破坏性_ 影响。请在一次性虚拟机或容器中运行它们。 ``` make check-integration ``` 还有一个 check-container 目标,它将在各种 podman/docker 容器内运行测试套件。这对于覆盖多个发行版很有用。它还运行可能对主机具有破坏性的测试,例如集成测试。 ``` make check-container TESTSUITEFLAGS="-j4" ``` ## OCI 容器镜像 作为 `dist` 构建目标的一部分,会生成一个 OCI 容器镜像。它与正常的发布 tarball 一起分发。它可用于从容器运行 firewalld。容器化的 firewalld 将 _不会_ 与主机集成(例如 podman、libvirt、NetworkManager)。 要手动将容器镜像加载到您的环境中: ``` podman load -i .../path/to/firewalld-oci-.tar ``` 要从 quay.io 获取镜像: ``` podman pull quay.io/firewalld/firewalld: ``` 其中 `` 是可选的,如果省略则使用最新版本。 要启动守护进程/容器: ``` podman run -d --network host --privileged \ --name my-firewalld firewalld ``` Firewalld 的配置将驻留在容器内部。因此用户可能希望偶尔 `podman commit` 该镜像。 使用 firewalld 的 CLI 应该在守护进程/容器启动后通过 podman exec 进行: ``` podman exec my-firewalld firewall-cmd ... ``` ### 与主机的容器集成 相同的容器镜像可用于与主机上运行的 NetworkManager、podman、libvirt 等集成。这要求主机具有针对 firewalld 的 dbus 策略。 可以从 firewalld 源代码树的 `config/FirewallD.conf` 位置获取 dbus 策略。 ``` cp config/FirewallD.conf /usr/share/dbus-1/system.d/FirewallD.conf ``` 一旦 dbus 策略就位,可以像这样启动容器: ``` podman run -d -v /run/dbus/system_bus_socket:/run/dbus/system_bus_socket \ --network host --privileged \ --name my-firewalld firewalld \ firewalld --nofork --nopid ``` 唯一的补充是:卷挂载、显式的 CMD。 相同的方法可用于将 firewalld 的配置文件存储在主机上。 ``` podman run -d -v /run/dbus/system_bus_socket:/run/dbus/system_bus_socket \ -v /etc/firewalld:/etc/firewalld \ --network host --privileged \ --name my-firewalld firewalld \ firewalld --nofork --nopid ``` ## RPM 软件包 对于基于 Fedora 和 RHEL 的发行版,源代码仓库中有一个名为 firewalld.spec 的 spec 文件。这应该适用于 Fedora 版本 >= 16 和 RHEL >= 7。 ## 链接 主页: http://firewalld.org 报告错误: https://github.com/firewalld/firewalld/issues Git 仓库浏览器: https://github.com/firewalld/firewalld Git 仓库: https://github.com/firewalld/firewalld.git 文档: http://firewalld.org/documentation/ ## 邮件列表 用于使用: https://lists.fedorahosted.org/archives/list/firewalld-users@lists.fedorahosted.org/ 用于开发: https://lists.fedorahosted.org/archives/list/firewalld-devel@lists.fedorahosted.org/ ## 目录结构 | 目录 | 内容 | | ----------------- | ----------------------------------------------------- | | config/ | 配置文件 | | config/icmptypes/ | 预定义的 ICMP 类型 | | config/services/ | 预定义的服务 | | config/xmlschema/ | 配置文件的 XML Schema 检查 | | config/zones/ | 预定义的区域 | | config/ipsets/ | 预定义的 ipsets | | doc/ | 文档 | | doc/man/ | man 页面的基础目录 | | doc/man/man1/ | Man(1) 页面 | | doc/man/man5/ | Man(5) 页面 | | po/ | 翻译 | | shell-completion/ | 自动完成脚本的基础目录 | | src/ | 源代码树 | | src/firewall/ | 服务和所有应用程序的导入树 | | src/icons/ | 以下尺寸的图标:16、22、24、32、48 和可缩放 | | src/tests/ | 测试套件 |
标签:Awesome, D-Bus, DNS解析, ebtables, firewalld, iptables, IPv4, IPv6, nftables, PowerShell, Python, 动态防火墙, 包过滤, 区域划分, 开源项目, 无后门, 永久配置, 状态检测, 系统管理, 系统集成, 网络安全, 网络工具, 网络防护, 运行时配置, 逆向工具, 防火墙, 隐私保护