查看防火墙状态

[root@localhost ~]# systemctl status firewalld.service    #查看防火墙状态(运行中)
[root@localhost ~]# systemctl stop firewalld.service    #关闭防火墙
[root@localhost ~]# systemctl disable firewalld.service   #禁止使用防火墙(重启也是禁止的) 如果是内网无所谓,如果是阿里云或者其他云建议不要这样做,开启防火墙策略即可
检查防火墙策略
[root@localhost ~]# firewall-cmd --list-all
将需要永久开放的端口加入防火墙
[root@localhost ~]# sudo firewall-cmd --zone=public --add-port=7001/tcp --permanent
重新加载防火墙
[root@localhost ~]# sudo firewall-cmd --reload # 重新加载完成后,再通过 firewall-cmd --list-all 命令查看防火墙的规则,端口已经加入进去
其他常用命令
[root@localhost ~]# systemctl restart firewalld
#检查防火墙状态
[root@localhost ~]# firewall-cmd --state
[root@localhost ~]# firewall-cmd --list-all
#Disable firewall
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl status firewalld
#Enable firewall
[root@localhost ~]# systemctl enable firewalld
[root@localhost ~]# systemctl start firewalld
[root@localhost ~]# systemctl status firewalld
posted on 2021-06-30 22:41  XIN1024  阅读(635)  评论(0)    收藏  举报