linux中防火墙操作命令

[root@VM-0-6-centos /]# firewall -cmd --list -all
-bash: firewall: command not found

 因为centos中没有安装firewall

安装firewall

[root@VM-0-6-centos /]# yum install firewalld 

启动命令

[root@VM-0-6-centos /]# systemctl start firewalld

停用命令

[root@VM-0-6-centos /]# systemctl stop firewalld

查看状态命令

[root@VM-0-6-centos /]# systemctl status firewalld

开机启动命令

[root@VM-0-6-centos /]# systemctl enable firewalld

开机禁用命令

[root@VM-0-6-centos /]# systemctl disable firewalld

 

注意:这里执行了开机启动命令和开机禁用命令后发现(粗心大意了!!!)

[root@VM-0-6-centos /]# systemctl status firewall
Unit firewall.service could not be found. 

  systemctl status firewalld 而不是 systemctl statusfirewall

yum install firewalld firewall-config
[root@VM-0-6-centos /]# service firewalld status
[root@VM-0-6-centos /]# service firewalld start
[root@VM-0-6-centos /]# service firewalld stop

查看firewall状态

 firewall-cmd --state

 查看firewall服务状态

systemctl status firewalld.service 

 查看防火墙规则(查看防火墙开放端口)

firewall-cmd --list-all

防火墙生效

firewall-cmd --reload

添加自定义开放端口(设置完后要让其生效firewall-cmd --reload)

firewall-cmd --zone=public --permanent --add-port=8090/tcp

 


版权声明:本文为qq_38423256原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。