systemctl mask firewalld

发布时间 2023-11-16 11:34:12作者: Bre-eZe

systemctl mask firewalld

systemctl --help

mask NAME...                    Mask one or more units
unmask NAME...                  Unmask one or more units


[root@hecs-98663 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
#enable实际上是创建一个软连接
[root@hecs-98663 ~]# systemctl enable firewalld
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.
#disable实际上是删除软连接
[root@hecs-98663 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
#enable与disable并不影响服务是否启动
[root@hecs-98663 ~]# systemctl start firewalld
#mask会创建连接,将服务指向为空
[root@hecs-98663 ~]# systemctl mask firewalld
Created symlink from /etc/systemd/system/firewalld.service to /dev/null.
#mask后就不能启动
[root@hecs-98663 ~]# systemctl start firewalld
Failed to start firewalld.service: Unit is masked.
#unmask  移除指向空的连接
[root@hecs-98663 ~]# systemctl unmask firewalld
Removed symlink /etc/systemd/system/firewalld.service.