1. 首页 > Linux教程 > 正文

Linux教程FG283-防火墙规则永久生效与重载命令

内容简介:本文风哥教程参考Linux官方文档、Red Hat Enterprise Linux官方文档、Ansible Automation Platform官方文档、Docker官方文档、Kubernetes官方文档和Podman官方文档等内容,详细介绍了相关技术的配置和使用方法。

本文档风哥主要介绍firewalld防火墙规则的永久生效与重载方法,包括运行时配置、永久配置、配置文件管理等内容。

Part01-基础概念与理论知识

1.1 firewalld配置类型

# 配置类型
1. 运行时配置(Runtime):立即生效,重启后失效
2. 永久配置(Permanent):重启后生效,需要重载

# 配置文件位置
/etc/firewalld/ – 用户自定义配置
/usr/lib/firewalld/ – 系统默认配置

Part02-生产环境规划与建议

2.1 配置管理策略

# 配置策略
1. 先测试运行时配置
2. 确认无误后添加更多学习教程公众号风哥教程itpux_com永久配置
3. 定期备份配置文件
4. 记录配置变更历史

Part03-生产环境项目实施方案

3.1 运行时配置

# 添加运行时规则(立即生效)
$ firewall-cmd –add-port=8080/tcp
success

# 查看运行时配置
$ firewall-cmd –list-ports
8080/tcp

# 移除运行时规则
$ firewall-cmd –remove-port=8080/tcp
success

3.2 永久配置

# 添加永久规则
$ firewall-cmd –permanent –add-port=8080/tcp
success

# 查看永久配置
$ firewall-cmd –permanent –list-ports
8080/tcp

# 重载配置使其生效
$ firewall-cmd –reload
success

# 完整重载(重置所有运行时配置)
$ firewall-cmd –complete-reload
success

3.更多视频教程www.fgedu.net.cn3 配置文件管理

# 查看配置文件
$ ls /etc/firewalld/
firewalld.conf lockdown-whitelist.xml services/ zones/

# 备份配置
$ tar -czf firewalld-backup-$(date +%Y%m%d).tar.gz /etc/firewalld/

# 恢复配置
$ tar -xzf firewall学习交流加群风哥微信: itpux-comd-backup-20260406.tar.gz -C /
$ firewall-cmd –reload

Part04-生产案例与实战讲解

4.1 案例:生产环境防火墙配置流程

# 步骤1: 测试运行时配置
$ firewall-cmd –add-port=8080/tcp
$ firewall-cmd –list-ports
8080/tcp

# 步骤2: 验证服务可访问
$ curl http://localhost:8080

# 步骤3: 添加永久配置
$ firewall-cmd –permanent –add-port=8080/tcp
success

# 步骤4: 重载配置
$ firewall-cmd –reload
success

# 步骤5: 验证永久配置
$ firewall-cmd –permanent –list-ports
8080/tcp

风哥提示:

Part05-风哥经验总结与分享

生产环境配置防火墙规则时,建议先使用运行时配置测试,确认无误后再添加–permanent选项。同时要定期备份配置文件,以便快速恢复。

本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html

联系我们

在线咨询:点击这里给我发消息

微信号:itpux-com

工作日:9:30-18:30,节假日休息