CentOS7开启关闭防火墙与端口 记录

本文详细介绍了在CentOS7系统中如何使用systemctl管理和控制防火墙服务,包括启动、停止、禁用服务以及查看状态。同时,讲解了firewall-cmd工具用于开启和关闭特定端口的操作,如添加和删除端口规则,并强调了规则的永久生效与重新加载。此外,还提供了检查服务启动状态、设置开机启动等实用技巧。
摘要由CSDN通过智能技术生成

1、开启关闭防火墙服务

查看状态: systemctl status firewalld 

启动: systemctl start firewalld

停止: systemctl disable firewalld

禁用: systemctl stop 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.开启关闭端口

查看帮助: firewall-cmd --help

显示状态: firewall-cmd --state

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

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

 

使用样本

添加

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

删除

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

重新载入,端口更改后需要重启后才能生效

firewall-cmd --reload

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值