CentOS 6 & CentOS 7 : 防火墙和SELinux的开启与关闭

防火墙服务程序

CentOS 6
  • 临时开启防火墙服务:/etc/init.d/iptables start
  • 临时关闭防火墙服务:/etc/init.d/iptables stop
  • 永久开启防火墙服务:chkconfig iptables on
  • 永久关闭防火墙服务:chkconfig iptables off
  • 查看防火墙服务状态:/etc/init.d/iptables status
CentOS 7
  • 临时开启防火墙服务:systemctl start firewalld
  • 临时关闭防火墙服务:systemctl stop firewalld.service
  • 永久开启防火墙服务:systemctl enable firewalld
  • 永久关闭防火墙服务:systemctl disable firewalld.service
  • 查看防火墙服务状态:systemctl status firewalld.service
  • 查看防火墙服务是否正在运行:systemctl is-active firewalld.service
  • 查看防火墙服务是否开机运行:systemctl is-enabled firewalld.service

SELinux

SELinux服务对root用户权限进行控制,很多企业默认关闭selinux服务程序。
关闭SElinux方法 :CentOS 6 = CentOS 7

  • getenforce:确认selinux服务是否开启或关闭

    [root@192 Desktop]# getenforce 
    Enforcing
    
  • setenforce:临时开启或关闭selinux服务

    [root@192 Desktop]# setenforce
    usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]
    
    Enforcing   1   --临时开启SElinux
    Permissive   0   --临时关闭SElinux
    
  • /etc/selinux/config文件:永久开启或关闭selinux服务(想要修改该配置文件后生效,需要重启系统)

    [root@192 Desktop]# 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.   --selinux处于正常开启状态
    #     permissive - SELinux prints warnings instead of enforcing.    --selinux处于临时关闭状态
    #     disabled - No SELinux policy is loaded.    --selinux服务处于彻底关闭状态
    SELINUX=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
    
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值