前言
对于不同版本打开和关闭防火墙的命令是不一样的。
centos
1.查看防火墙的状态
[xiaocer@localhost ~]$ firewall-cmd --state
然后呢显示结果不是not running
就是running
。我的已经关闭了防火墙所以显示not running.
2.检查防火墙的状态
[root@localhost xiaocer]# systemctl list-unit-files|grep firewalld.service
然后显示firewalld.service disabled
3.关闭防火墙
##停止防火墙
[xiaocer@localhost ~]$ sudo systemctl stop firewalld.service
##停止防火墙也可以这样
[xiaocer@localhost ~]$ sudo systemctl stop firewalld
##禁止firewall开机启动
[xiaocer@localhost ~]$ sudo systemctl disable firewalld.service
4.重启防火墙
##重启防火墙
[xiaocer@localhost ~]$sudo systemctl start firewalld
##或者
[xiaocer@localhost ~]$sudo systemctl restart firewalld
Ubuntu
1.查看防火墙的状态
sudo ufw status
标签:重启,sudo,防火墙,firewalld,xiaocer,systemctl,关闭,localhost
From: https://www.cnblogs.com/xiaocer/p/16622332.html