CentOS7使用firewalld打开关闭防火墙与端口

开发者福利!热门AI工具限时免费用 购周边即赠Coding Plan Lite,Claude Code、Cursor等20+工具畅享,效率翻倍! 阅读详情

1、firewalld的基本使用

启动: systemctl start firewalld

关闭: systemctl stop firewalld

查看状态: systemctl status firewalld 

开机禁用  : systemctl disable firewalld

开机启用  : systemctl enable firewalld

 

 

2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

启动一个服务: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

3.配置firewalld-cmd

查看版本: firewall-cmd --version

查看帮助: firewall-cmd --help

显示状态: firewall-cmd --state

查看所有打开的端口: firewall-cmd --zone=public --list-ports

更新防火墙规则: firewall-cmd --reload

查看区域信息:  firewall-cmd --get-active-zones

查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0

拒绝所有包:firewall-cmd --panic-on

取消拒绝状态: firewall-cmd --panic-off

查看是否拒绝: firewall-cmd --query-panic

 

那怎么开启一个端口呢

添加

firewall-cmd --zone=public --add-port=80/tcp --permanent    (--permanent永久生效,没有此参数重启后失效)

重新载入

firewall-cmd --reload

查看

firewall-cmd --zone= public --query-port=80/tcp

删除

firewall-cmd --zone= public --remove-port=80/tcp --permanent

1. 查看已打开的端口 # netstat -anp

2. 查看想开的端口是否已开 # firewall-cmd --query-port=666/tcp 若此提示 FirewallD is not running 表示为不可知的防火墙 需要查看状态并开启防火墙

3. 查看防火墙状态 # systemctl status firewalld running 状态即防火墙已经开启 dead 状态即防火墙未开启

4. 开启防火墙,# systemctl start firewalld 没有任何提示即开启成功

5. 开启防火墙 # service firewalld start 关闭防火墙 # systemctl stop firewalld centos7.3 上述方式可能无法开启,可以先#systemctl unmask firewalld.service 然后 # systemctl start firewalld.service

6. 查看想开的端口是否已开 # firewall-cmd --query-port=666/tcp 提示no表示未开

7. 开永久端口号 firewall-cmd --add-port=666/tcp --permanent 提示 success 表示成功

8. 重新载入配置 # firewall-cmd --reload 比如添加规则之后,需要执行此命令

9. 再次查看想开的端口是否已开 # firewall-cmd --query-port=666/tcp 提示yes表示成功

10. 若移除端口 # firewall-cmd --permanent --remove-port=666/tcp

11. 修改iptables 有些版本需要安装iptables-services # yum install iptables-services 然后修改进目录 /etc/sysconfig/iptables 修改内容 
 

RTL8306MB交换芯片驱动开发避坑指南:从硬件接线到SDK移植全流程解析 本文详细解析了RTL8306MB交换芯片驱动开发的全流程,重点从硬件接线、SDK移植到实战调试。针对RMII模式下的常见问题,特别是TXENRXDV信号交叉连接等关键“坑点”,提供了清晰的排查指南和解决方案,旨在帮助嵌入式工程师高效完成网络设备开发。 阅读详情

相关推荐

Anomalib实战指南:从零开始构建自定义异常检测数据集

本文提供了一份详细的Anomalib实战指南,指导用户从零开始构建自定义异常检测数据集。文章深入解析了数据准备的核心步骤、目录结构规范,并对比了PatchCoreFastFlow等关键模型的适用场景。通过清晰的代码示例,手把手演示了环境配置、模型训练推理评估的全流程,旨在帮助开发者快速掌握这一工业视觉异常检测利器,有效解决实际生产中的缺陷识别难题。

weixin_29054245的博客 611

Linux之firewall防火墙关闭

Linux基础知识学习:firewall防火墙关闭

. 1983

第七天 Labview进阶(7.2 汇川PLC通信)

运行环境: Labview 2020 Autoshop v4.10.1.1 该文档中包括Labview程序和汇川PLC程序,可以完美实现Labview汇川PLC的通信。具体的使用教程可以参考本人的相关文章,讲解详尽,请尽情享用!

weixin_38637405的博客 3453

Linux防火墙和firewall-cmd命令应用

记录:341 场景:在CentOS 7.9操作系统上,操作防火墙firewalld,主要是查看、开启、关闭以及禁用等。firewall-cmd命令查看防火墙和修改防火墙相关配置。

zhangbeizhen18的博客 3345

Can't open /dev/tty: No such device or address Error (Linux)

前言 由于之前的线上服务器替换过ip地址,导致线下服务器crontab在拉取备份日志时日志里记录了如下问题(ps:在家边解决bug边看我是歌手,很爽啊): 注意: 查找服务器端问题一定要查看日志,不能靠猜,例如ssh的问题可以多加-vvv参数来具体排查问题 原因 线上服务器进行了ip地址的修改,开始出现Host key verification failed的时...

系统运维 3241

Linux防火墙(firewalld)使用方法

防火墙服务操作: 启动防火墙# systemctl start firewalld 关闭防火墙# systemctl stop firewalld 重启防火墙# systemctl restart firewalld 查看防火墙状态# systemctl status firewalld 设置防火墙开机启动# systemctl enable firewalld 关闭防火墙开机启动# systemctl disable firewalld 常用命令(加--permanent参数才会写入配置文

weixin_51697917的博客 9186

防火墙firewall-cmd用法

注:**-permanent参数表示永久生效设置,如果没有指定-zone参数,则加入默认区域。1、查看防火墙开放的所有端口7、查看防火墙默认的域。3、查看端口是否开启。4、重新载入防火规则。

weixin_49278803的博客 2400

CentOS7使用httpd apache 和firewalld打开关闭防火墙端口

CentOS7使用httpd apache 和firewalld打开关闭防火墙端口 CentOS7使用systemctl工具操作命令 第一、启动、终止、重启 systemctl start httpd.service #启动 systemctl stop httpd.service #停止 systemctl restart httpd.service #重启 第二、设置开机启动/关闭 syst...

weixin_41915416的博客 1367

Linux 之CentOS7使用firewalld打开关闭防火墙端口

Linux 之CentOS7使用firewalld打开关闭防火墙端口 一、firewalld的基本使用   启动: systemctl start firewalld   关闭: systemctl stop firewalld   查看状态: systemctl status firewalld   开机禁用 : systemctl disable firewalld   开机启用 : systemctl enable firewalld 二、systemctl介绍 它是CentOS7的服务管

wtt234的专栏 233

linux关闭防火墙firewalld,【防火墙CentOS7使用firewalld打开关闭防火墙端口

防火墙CentOS7使用firewalld打开关闭防火墙端口2年前 (2019-04-28) 作者:Jiaozn 分类:Linux 阅读次数:693评论(0)1、firewalld的基本使用启动: systemctl start firewalld关闭: systemctl stop firewalld查看状态: systemctl status firewalld开机禁用...

weixin_28779183的博客 497

Linux-CentOS7使用firewalld打开关闭防火墙端口

Linux-CentOS7使用firewalld打开关闭防火墙端口 仅仅适用于centos7(其他版本于此不太相同,centos7以上的版本我个人没用过,自行查阅或实践测试) 一、firewalld的基本使用 启动: systemctl start firewalld 关闭:systemctl stop firewalld 查看状态: systemctl status firewalld 开机禁用 : systemctl disable firewalld 开机启用 : systemctl ena

weixin_43558205的博客 305

centos7使用firewalld打开关闭防火墙端口

CentOS7使用firewalld打开关闭防火墙端口 1、firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop firewalld 查看状态: systemctl status firewalld : 开机禁用 : systemctl disable firewalld 开机启用 : systemctl ...

爷来辣的博客 844

CentOS7-运维-使用firewalld打开关闭防火墙端口

firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop firewalld 查看状态: systemctl status firewalld 开机禁用: systemctl disable firewalld 开机启用:systemctl enable firewalld systemctl是CentOS7的服务管理工...

weixin_42713970的博客 186
上一篇: laravel 发送短信
下一篇: CentOS7 Firewall防火墙配置用法详解
angelo_gs
博客等级 码龄9年 14粉丝 66原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值