永久关闭防火墙和SElinux

120 阅读1分钟

1、防火墙

1.1 打开防火墙(不建议使用)

systemctl start firewalld

1.2 关闭防火墙

此为临时关闭,开机后防火墙会重新启动!

systemctl stop firewalld

1.3 查看防火墙状态

systemctl status firewalld

1.4 永久关闭防火墙

systemctl disable firewalld
systemctl disable --now firewalld

2、selinux

2.1 临时关闭SElinux

setenforce 0

2.2 永久关闭SElinux

[root@7-1 ~]#  vim /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.   
#     disabled - No SELinux policy is loaded.
SELINUX=disabled                                           //将enforcing改为disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

重启reboot后,才会生效。

2.3 查看SElinux状态

[root@7-1 ~]#  setenforce 0     //0是宽容
[root@7-1 ~]#  getenforce      //查看
Permissive                    //宽容

[root@7-1 ~]#  setenforce 1   //1是强制
[root@7-1 ~]#  getenforce
Enforcing                    //强制,相当于开启

永久关闭后查看:
[root@7-1 ~]#  getenforce
Disabled                    //永久关闭SElinux