Linux firewall

安装防火墙:

1.查看防火墙状态:
systemctl status firewall

[root@localhost ~]# systemctl status firewall
Unit firewalldd.service could not be found. #未安装

2.安装防火墙服务:
yum install firewalld systemd -y


[root@localhost ~]# yum install firewalld systemd -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 firewalld.noarch.0.0.6.3-8.el7 将被 升级
--> 正在处理依赖关系 firewalld = 0.6.3-8.el7,它被软件包 firewall-config-0.6.3-8.el7.noarch 需要
---> 软件包 firewalld.noarch.0.0.6.3-8.el7_8.1 将被 更新
--> 正在处理依赖关系 python-firewall = 0.6.3-8.el7_8.1,它被软件包 firewalld-0.6.3-8.el7_8.1.noarch
需要
--> 正在处理依赖关系 firewalld-filesystem = 0.6.3-8.el7_8.1,它被软件包 firewalld-0.6.3-8.el7_8.1.no
arch 需要
---> 软件包 systemd.x86_64.0.219-73.el7.1 将被 升级
--> 正在处理依赖关系 systemd = 219-73.el7.1,它被软件包 systemd-python-219-73.el7.1.x86_64 需要
--> 正在处理依赖关系 systemd = 219-73.el7.1,它被软件包 systemd-sysv-219-73.el7.1.x86_64 需要
---> 软件包 systemd.x86_64.0.219-73.el7_8.5 将被 更新
--> 正在处理依赖关系 systemd-libs = 219-73.el7_8.5,它被软件包 systemd-219-73.el7_8.5.x86_64 需要
--> 正在检查事务
---> 软件包 firewall-config.noarch.0.0.6.3-8.el7 将被 升级
---> 软件包 firewall-config.noarch.0.0.6.3-8.el7_8.1 将被 更新
---> 软件包 firewalld-filesystem.noarch.0.0.6.3-8.el7 将被 升级
---> 软件包 firewalld-filesystem.noarch.0.0.6.3-8.el7_8.1 将被 更新
---> 软件包 python-firewall.noarch.0.0.6.3-8.el7 将被 升级
---> 软件包 python-firewall.noarch.0.0.6.3-8.el7_8.1 将被 更新
---> 软件包 systemd-libs.x86_64.0.219-73.el7.1 将被 升级
--> 正在处理依赖关系 systemd-libs = 219-73.el7.1,它被软件包 libgudev1-219-73.el7.1.x86_64 需要
---> 软件包 systemd-libs.x86_64.0.219-73.el7_8.5 将被 更新
---> 软件包 systemd-python.x86_64.0.219-73.el7.1 将被 升级
---> 软件包 systemd-python.x86_64.0.219-73.el7_8.5 将被 更新
---> 软件包 systemd-sysv.x86_64.0.219-73.el7.1 将被 升级
---> 软件包 systemd-sysv.x86_64.0.219-73.el7_8.5 将被 更新
--> 正在检查事务
。。。。。。

3.启用防火墙:

systemctl start firewalld.service

4.关闭防火墙:

systemctl stop firewalld.service

5开机启动防火墙:

systemctl enable firewalld.service

[root@localhost ~]# systemctl enable firewalld.service
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/syste

md/system/firewalld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/syste

md/system/firewalld.service.

6.开机不启动防火墙:
systemctl disable firewalld.service

[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

原文地址:https://www.cnblogs.com/donglian1/p/12857334.html