Linux 防火墙和SELinux的开启和关闭

2018/10 16 15:10

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/SaberJYang/article/details/69665927

防火墙(firewalld)

  • 临时关闭防火墙
    systemctl stop firewalld
  • 永久防火墙开机自关闭
    systemctl disable firewalld
  • 临时打开防火墙
    systemctl start firewalld
  • 防火墙开机启动
    systemctl enable firewalld
  • 查看防火墙状态
    systemctl status firewalld
[root@localhost ~] # systemctl status firewalld

● firewalld.service
 - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: ena  bled)

   Active: active (running) since Sat 2017-04-0810:36:57 CST; 31s ago

 Main PID: 2856
 (firewalld)
   CGroup: /system.slice/firewalld.service

           └─2856

 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Apr 0810:36:56 localhost.localdomain systemd[1
]: Starting firewalld - dynamic firewal....
Apr 0810:36:57 localhost.localdomain systemd[1
]: Started firewalld - dynamic firewall....
Hint: Some lines were ellipsized, use -l to show in

full.
[root@localhost ~] #
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

SELinux

  • 临时关闭SELinux
    setenforce 0
  • 临时打开SELinux
    setenforce 1
  • 查看SELinux状态
    getenforce
  • 开机关闭SELinux
    编辑/etc/selinux/config文件,如下图,将SELINUX的值设置为disabled。下次开机SELinux就不会启动了。
    这里写图片描述

注意,此时也不能通过setenforce 1命令临时打开。

[root@localhost ~]# setenforce 1
setenforce: SELinux is disabled
  • 1
  • 2

需要修改配置文件,然后重启linux后,才可以再打开SELinux

--转载请注明: http://91o.cc/linux-%e9%98%b2%e7%81%ab%e5%a2%99%e5%92%8cselinux%e7%9a%84%e5%bc%80%e5%90%af%e5%92%8c%e5%85%b3%e9%97%ad/

作者 - 分类 未分类

发表回复

(必填)