1. 查看防火墙状态:active (running) 即是开启状态
| systemctl status firewalld |

2. 如果不是显示 active 状态,需要打开防火墙
| |
| systemctl start firewalld |
| |
| |
| systemctl status firewalld |
| |
| |
| systemctl enable firewalld |

3.如果是显示 active 状态,需要关闭防火墙
| |
| systemctl stop firewalld |
| |
| |
| systemctl status firewalld |
| |
| |
| systemctl disable firewalld |

4.查看所有已开放的端口
| |
| firewall-cmd --list-ports |
| |
| firewall-cmd --list-ports --permanent |
5.新增防火墙开放端口
| firewall-cmd --zone=public --add-port=3306/tcp --permanent |
| |
| 命令含义: |
| --zone |
| --add-port=3306/tcp |
| --permanent |
| |
| |
| firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=<ip>/24 port protocol=tcp port=22 accept' |
| |
| |
| firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=<ip> port protocol=tcp port=3306 accept' |

6.关闭防火墙端口
| |
| firewall-cmd --remove-port=80/tcp |
| |
| firewall-cmd --remove-port=80/tcp --permanent |
7.systemctl相关命令
| |
| systemctl start firewalld.service |
| |
| |
| systemctl stop firewalld.service |
| |
| |
| systemctl restart firewalld.service |
| |
| |
| systemctl status firewalld.service |
| |
| |
| systemctl enable firewalld.service |
| |
| |
| systemctl disable firewalld.service |
| |
| |
| systemctl is-enabled firewalld.service |
| |
| |
| systemctl list-unit-files|grep enabled |
| |
| |
| systemctl --failed |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· 2 本地部署DeepSeek模型构建本地知识库+联网搜索详细步骤