【CentOS】防火牆firewalld

CentOS7 採用firewalld做爲防火牆,以前是採用iptables做爲防火牆。 服務器沒法鏈接多是防火牆限制的緣由。
修改防火牆配置。修改完後須要重啓生效:firewall-cmd --reload
 

一、直接修改配置文件:/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>

二、經過命令修改配置

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

三、經常使用命令

查看防火牆狀態:systemctl status firewalld.service
啓動防火牆:systemctl start firewalld.service
關閉防火牆:systemctl stop firewalld.service
從新啓動防火牆:systemctl restart firewalld.service
相關文章
相關標籤/搜索