【CentOS】防火墙firewalld

CentOS7 采用firewalld作为防火墙,之前是采用iptables作为防火墙。服务器无法连接可能是防火墙限制的原因。

修改防火墙配置。修改完后需要重启生效:firewall-cmd --reload

 

1、直接修改配置文件:/etc/firewalld/zones/public.xml(白名单模式)

<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. 
You do not trust the other computers on networks to not harm your computer. 
Only selected incoming connections are accepted.</description>
<servicename="dhcpv6-client"/>
<servicename="http"/> <!--允许http协议 -->
<servicename="ssh"/> <!--允许ssh协议 -->
<servicename="https"/> <!--允许https协议 -->
</zone>

2、通过命令修改配置

##Add
firewall-cmd --permanent --zone=public--add-port=80/tcp
##Remove
firewall-cmd --permanent --zone=public--remove-port=80/tcp
##Reload
firewall-cmd --reload

3、常用命令

查看防火墙状态:systemctl status firewalld.service

启动防火墙:systemctl start firewalld.service

关闭防火墙:systemctl stop firewalld.service

重新启动防火墙:systemctl restart firewalld.service

--------------------------------------------------------------------
承接网站开发、小程序开发、app开发、商城开发、公众号开发。
百度SEO排名、百度搜索霸屏、软文代写等业务。
联系QQ:2779459018     联系微信:qianxia39

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值