Red hat/CentOS7启用/关闭防火/端口开启

 1.启用防火墙

复制代码
  systemctl start firewalld

防火墙设置开机自启动 systemctl enable firewalld

  防火墙禁用开机自启动
   systemctl disable firewalld
  加载防火墙配置
   firewall-cmd --relaod
  或者

   systemctl reload firewalld

复制代码

 

2.查看防火状态

systemctl status firewalld

service  iptables status

firewall-cmd --state

 

3.暂时关闭防火墙

systemctl stop firewalld

service  iptables stop

 

4.永久关闭防火墙

systemctl disable firewalld

chkconfig iptables off

 

5.重启防火墙

systemctl enable firewalld

service iptables restart  

 

6.永久关闭后重启

chkconfig iptables on

 

7 查看已打开的端口

# firewall-cmd --list-ports
查看公共作用域,永久打开的端口:

# firewall-cmd --permanent --zone=public --list-ports

 

8 验证某一端口是否生效

# firewall-cmd --zone=public --query-port=8080/tcp
8080是查询的端口号。

 

9 添加端口

# firewall-cmd --zone=public --add-port=8080/tcp --permanent 

参数说明: zone ——作用域,public指公共的作用域; add-port ——添加端口,8080/tcp表示添加的端口号及类型; permanent ——表示永久添加,不加表示临时添加。

 

10 关闭端口

# firewall-cmd --zone=public --remove-port=8080/tcp --permanent


**注**:只要添加或关闭端口,都要重新加载防火墙配置,才能生效。

 



 

posted @   O波V步  阅读(400)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
点击右上角即可分享
微信分享提示