gbmin's Tech Notes

서버 구축 및 유지보수, 클라우드 컴퓨팅, 네트워크 보안, IT 분야 기술 노트. :)

Tech Notes/Linux

centos - SELinux 설정 및 해제

gbmin 2023. 5. 2. 22:33

SELinux(Security Enhanced Linux)는 RHEL, CentOS 기반의 리눅스 보안 프로그램이다.
특정 서비스가 SELinux로 인해 정상 동작 하지 않는 다면 끄기보다는
SELinux 가 활성화 된 상태에서 동작되도록 설정을 수정하는 것이 좋다.

 

SELinux 상태 확인

# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      33

enabled는 SELinux가 활성화되어 있다는 것을 나타내며, disabled는 비활성화되어 있다는 것을 나타낸다.
Current mode 부분에서는 현재 SELinux가 Enforcing 모드로 작동하는지, Permissive 모드로 작동하는지 확인할 수 있다.
Permissive 모드는 룰에 감지된 명령을 로그에 남기고 허용하는 모드이다.

Permissive mode 전환 방법

# setenforce 0 
# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      33


SELinux 설정 해제 방법

# vi /etc/selinux/config  
SELINUX=disabled

설정 후 재부팅

 

centos8, Rocky Linux 버전에 따라 아래 경로로 설정되어 있을 수 있다.
/etc/sysconfig/SELinux