ubuntu:防火墙配置详细讲解(全)

关于防火墙如出现以下问题等都可以用这种方法解决
比如找不到该命令行

Failed to stop firewalld.service: Unit firewalld.service not loaded.
在这里插入图片描述

或者是无法关闭无法启动等

Failed to start firewalld.service: Unit not found. Unit firewalld.service could no


出现如上问题都可以这样解决
首先正常启动防火墙systemctl unmask firewalld.service

如果启动不成功或者没有这个命令行
则需要先安装或者是先关闭启动等
在ubuntu执行service iptables stop关闭防火墙的一些命令时
会出现找不到这个命令等内容
由于系统的不断更新迭代
已经将这个命令变成了firewall作为防火墙
如果这个防火墙的命令还没有以及没有安装
可以通过apt-get install firewall安装

如果想要关闭防火墙可以执行
systemctl stop firewalld.service

如果想要打开防火墙可以执行

systemctl unmask firewalld
systemctl enable firewalld
systemctl start firewalld

完成后,就可以对该防火墙上的命令进行启动关闭等操作
具体命令讲解为
开启防火墙systemctl start firewalld.service
关闭防火墙systemctl stop firewalld.service
开机自动启动systemctl enable firewalld.service
禁止开机启动systemctl disable firewalld.service
在不改变状态的条件下重新加载防火墙firewall-cmd --reload
修改配置后需要重启服务使其生效systemctl restart firewalld.service


其他命令行:
启动服务

firewall-cmd --zone=public --add-service=https   //临时
firewall-cmd --permanent --zone=public --add-service=https  //永久

启动端口号

firewall-cmd --permanent --zone=public --add-port=端口号 //永久
firewall-cmd  --zone=public --add-port=端口号   //临时

查看是否启动成功
有这项服务或者端口号

firewall-cmd --permanent --zone=public --list-services   
firewall-cmd --permanent --zone=public --list-ports 

以上所有的端口号记得在后面加上协议
不然会出错哦
正确的方式应该为[端口号/协议]

你可能感兴趣的:(配置,linux,java,linux,ubuntu)