首页 > 技术文章 > linux防火墙firewalld

hongzuiliyu 2021-05-11 19:25 原文

开启防火墙

  systemctl enable firewalld

  systemctl start firewalld

 

关闭防火墙

  systemctl stop firewalld

  systemctl disable firewalld

 

查看防火墙规则

  firewall-cmd --list-all

 

通过防火墙限制ip访问

  firewall-cmd --permanent --zone=public --add-rich-rule="rule family=ipv4 source address='x.x.x.x' port port=xxxxx procotol=tcp accept"

  实际上相当于修改了/etc/firewalld/zones/public.xml文件

    

 

   还可以通过区分zone的方式,对ip访问进行更加细粒度的控制,zone相当于组,不同的组下配置不同的访问规则。

 

清除防火墙规则     firewall-cmd --permanent --zone=public --remove-rich-rule="rule family=ipv4 source address='x.x.x.x' port port=xxxxx procotol=tcp accept"

 

参考文档:  

  

推荐阅读