OS/Rocky Linux

Rocky 8 기본 환경 설정

Shirou_Techblog 2023. 6. 20. 19:09
반응형

Rocky 8.8 Minimal 버전

root 권한

# Command

1. Hostname 변경

  • 현재 Hostname 확인
  • # hostname
  • Default로 설치하였을 때 hostname localhost.localdomain

1.1 nmtui 툴 사용

  • # nmtui 실행
  • 시스템의 호스트 이름 설정 > 호스트 이름 변경
  • 영구 적용 / 재부팅 필요 없음 (즉시적용)

1.2 hostnamectl 명령

  • # hostnamectl set-hostname 'rocky-mariadb'
  • 영구 적용 / 재부팅 필요 없음 (즉시적용)

1.3 hostname 편집

  • # vi /etc/hostname
  • 영구 적용 / 재부팅 필요

2. 보안기능

2.1 SELinux

SELinux는 리눅스의 보안 기능으로, 파일과 같은 리눅스의 리소스에 대한 접근 권한을 제어할 수 있다.

어떤 프로세스가 어떤 파일, 디렉터리, 포트에 접근 가능한지 세부적인 규칙을 설정할 수 있게 된다.

하지만 일반적으로 인프라에 방화벽 또는 보안 시스템이 포함되어 있으므로 Disable 처리를 한다.

/etc/selinux/config 에서 커널 파라미터를 변경해야 하며, 재부팅이 필요하다.

 

1) SELINUX 항목을 disable로 변경 (재부팅 필요)
# vi /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
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

===================================================================

 

2) setenforce 명령

# setenforce 0
Permissive 상태로 변경한 상태이며, Disable하려면 /etc/selinux/config 이 변경된 상태로 재부팅이 필요하다.

# setenforce ?
usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]

# getenforce
현재 SELinux 모드를 확인할 수 있다.
SELinux Modes

- Enforcing
접근 제어 룰이 허용된 상태
- Permissive
SELinux 의 접근 제어 룰이 적용 되지는 않고, 위반 된 사항들만 로그로 남기는 상태
- Disabled
SELinux가 완전히 비활성화 된 상태

2.2 방화벽설정

외부에서 시스템으로 접근하는 패킷을 차단하는 서비스이다.

일반적으로 인프라구성시 방화벽이 포함되어 있어 OS 방화벽은 Disable 한다.

 

1) 방화벽 중지 및 Disable 처리

$ systemctl stop firewalld
$ systemctl disable firewalld
$ systemctl status firewalld

3. 시간동기화

 3.1 Chrony

Chrony NTP를 같이 사용할 수 없으며, Rocky8, Centos Stream, RHEL8 이상의 버전에서는 ntpd를 지원하지 않는다.

 

1) Chrony 설치
# dnf install chrony.x86_64


2) 환경 설정
# vi /etc/chrony.conf
== 상세 설명 생략==

===================================================================

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#pool 2.rocky.pool.ntp.org iburst  >> Default 서버 설정 주석 처리
server time.bora.net iburst >> Time Server IP 입력
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

===================================================================

 

 3) 서비스 기동 및 Enable, 서비스 현황 확인
# systemctl start chronyd
# systemctl enable chronyd
# systemctl status chronyd
 
4) Chrony 동기화 확인
# chronyc sources

 

동기화 상태 확인
M : ^(서버), =(피어), #(로컬)
S : *(현재 동기화중), +(등록한 소스와 동기화 가능), -(등록한 소스와 동기화 불가능),
 ?(응답 없음/Unreachable), x(서버와 시간차 큼)
 
5) 동기화 추적
# chronyc tracking
 
6) 즉시동기화
# chronyc -a makestep
 
7) TimeZone 및 시간확인
# timedatactl
 
8) TimeZone 변경
 - Timezone list
# timedatectl list-timezones
모든 타임존이 확인되며 grep으로 변경 도시명을 확인한다.
Ex) # timedatectl list-timezones|grep Seoul
Asia/Seoul
 - 타임존 변경
# timedatectl set-timezone Asia/Seoul

 

 3.2 NTP

1) NTP 설치
== 생략 ==


2) 환경 설정
# vi /etc/ntp.conf
상세 설명 생략

===================================================================
#server 0.centos.pool.ntp.org iburst >> Default 서버 설정 주석 처리
#server 1.centos.pool.ntp.org iburst >> Default 서버 설정 주석 처리
#server 2.centos.pool.ntp.org iburst >> Default 서버 설정 주석 처리
#server 3.centos.pool.ntp.org iburst >> Default 서버 설정 주석 처리
server time.bora.net iburst >> Time Server IP 입력
===================================================================
3) 서비스 기동 및 Enable, 서비스 현황 확인
$ systemctl start ntpd
$ systemctl enable ntpd
$ systemctl status ntpd
 
4) Time Server 동기화 확인
$ ntpq -p

동기화 상태 확인
# * 표기가 현재 동기화 중인 서버
# + 표시는 동기화 후보
 
5) 시간확인
$ timedatactl

4. 리소스 제한 설정

프로세스 생성 개수 및 최대 오픈 파일 개수 설정

 

1.     Limits 설정(필요시 설정)
# vi /etc/security/limits.conf

  • soft : 새로운 프로그램을 생성하면 기본으로 적용되는 한도
  • hard : 최대로 늘릴 수 있는 한도
  • nproc (number of processes) : 프로세스 최대 개수
  • nofile (number of open files) : 파일 열기 최대 개수
  • 예시) 모든 사용자에게 적용
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535

5. 기타 환경 설정

5.1 OS 패스워드 만료일 관리

계정 관리 시스템이 없는 경우 패스워드가 만료되면 로그인 및 crontab이 실행되지 않아 프로세스 감시 및 로그 백업 등이 실행되지 않아 장애가 발생할 수 있다.

 

1) 비밀번호 만료일 해제
# chage -E -1 root
# chage -E -1 user
 
2) 비밀번호 설정 현황
# chage -l root
# chage -l user
암호를 바꾼날, 계정 만료, 바꿔야 하는 날 수 등 정보를 확인할 수 있다.
 
3) 옵션 설명
chage <USERNAME>
# -d : 비밀번호 변경일 설정
# -m : 비밀번호 변경 불가 기간 설정
# -M : 비밀번호 사용 가능 기간 설정
# -I : 비밀번호 변경 유도 기간 설정
# -E : 계정 만료일 설정
# -l : 설정된 비밀번호 사용 기간 확인

 

 

반응형