Rocky9: 두 판 사이의 차이
새 문서: = Rocky Linux 9 초기 설치 및 기본 서버 설정 가이드 = == 문서 개요 == 본 문서는 Rocky Linux 9 또는 RHEL 9 계열 운영체제를 처음 설치한 후 기본 서버로 사용하기 위한 설정 절차를 설명한다. 다음 순서로 진행한다. # 운영체제 설치 # CLI에서 IP 주소 설정 # 호스트 이름 설정 # SSH 기본 설정 # SSH 특정 계정 접속 제한 # SSH 포트 변경 # firewalld 포트 허용 # firewalld 비활성... |
편집 요약 없음 |
||
| 3번째 줄: | 3번째 줄: | ||
== 문서 개요 == | == 문서 개요 == | ||
본 문서는 Rocky Linux 9 또는 RHEL 9 계열 운영체제를 처음 설치한 후 기본 서버로 사용하기 위한 설정 절차를 설명한다. | 본 문서는 Rocky Linux 9 또는 RHEL 9 계열 운영체제를 처음 설치한 후 | ||
기본 서버로 사용하기 위한 초기 설정 절차를 단계별로 설명한다. | |||
다음 순서로 진행한다. | 다음 순서로 진행한다. | ||
# 운영체제 설치 | # 운영체제 설치 | ||
# 설치 직후 기본 확인 | |||
# CLI에서 IP 주소 설정 | # CLI에서 IP 주소 설정 | ||
# 네트워크 인터페이스 본딩 설정 | |||
# 구형 ifcfg 파일 형식 적용 | |||
# 호스트 이름 설정 | # 호스트 이름 설정 | ||
# SSH 기본 설정 | # SSH 기본 설정 | ||
# SSH 특정 계정 접속 제한 | # SSH 특정 계정 접속 제한 | ||
# SSH 포트 변경 | # SSH 포트 변경 | ||
# firewalld 포트 허용 | # firewalld 포트 허용 | ||
# firewalld 비활성화 및 iptables 전환 | # firewalld 비활성화 및 iptables 전환 | ||
# 서비스 상태 및 포트 확인 | # 서비스 상태 및 포트 확인 | ||
# SSH 및 SFTP 접속 테스트 | # SSH 및 SFTP 접속 테스트 | ||
# Samba 파일 공유 설정 | # Samba 파일 공유 설정 | ||
# 전체 설정 최종 점검 | |||
본 문서의 명령어는 기본적으로 root 계정으로 실행하는 것을 기준으로 한다. | 본 문서의 명령어는 기본적으로 root 계정으로 실행하는 것을 기준으로 한다. | ||
일반 계정으로 실행할 경우 명령어 앞에 | 일반 계정으로 실행할 경우 명령어 앞에 sudo를 추가한다. | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 44번째 줄: | 39번째 줄: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |||
! 이미지 종류 | ! 이미지 종류 | ||
! 설명 | ! 설명 | ||
! 권장 용도 | |||
|- | |||
| - | | DVD ISO | ||
| DVD ISO | | 운영체제 설치에 필요한 대부분의 패키지가 포함되어 있다. | ||
| 운영체제 설치에 필요한 대부분의 패키지가 포함되어 있다. | | 인터넷 연결이 제한된 환경 | ||
| 인터넷 연결이 제한된 환경 | |- | ||
| - | | Boot ISO | ||
| Boot ISO | | 최소 설치 이미지이며 설치 중 인터넷 저장소에 연결한다. | ||
| 최소 설치 이미지이며 설치 중 인터넷 저장소에 연결한다. | | 인터넷 연결이 가능한 환경 | ||
| 인터넷 연결이 가능한 환경 | |} | ||
| } | |||
서버 환경에서는 일반적으로 DVD ISO 사용을 권장한다. | 서버 환경에서는 일반적으로 DVD ISO 사용을 권장한다. | ||
| 67번째 줄: | 62번째 줄: | ||
=== 1.3 BIOS 또는 UEFI 설정 === | === 1.3 BIOS 또는 UEFI 설정 === | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |||
! 항목 | ! 항목 | ||
! 권장 설정 | |||
|- | |||
| - | | Boot Mode | ||
| Boot Mode | | UEFI | ||
| UEFI | |- | ||
| - | | Secure Boot | ||
| Secure Boot | | 일반적으로 활성화 가능 | ||
| 일반적으로 활성화 가능 | |- | ||
| - | | SATA Mode | ||
| SATA Mode | | AHCI | ||
| AHCI | |- | ||
| - | | Virtualization | ||
| Virtualization | | 가상화 사용 시 활성화 | ||
| 가상화 사용 시 활성화 | |- | ||
| - | | Boot Priority | ||
| Boot Priority | | USB 설치 장치를 첫 번째로 설정 | ||
| USB 설치 장치를 첫 번째로 설정 | |} | ||
| } | |||
=== 1.4 설치 화면 진입 === | === 1.4 설치 화면 진입 === | ||
| 102번째 줄: | 91번째 줄: | ||
Install Rocky Linux 9 | Install Rocky Linux 9 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 1.5 설치 대상 디스크 설정 === | === 1.5 설치 대상 디스크 설정 === | ||
초심자는 자동 파티션 구성을 사용할 수 있다. | |||
초심자는 자동 파티션 구성을 | |||
서버 용도로 별도 파티션을 구성하려면 다음 예시를 참고한다. | 서버 용도로 별도 파티션을 구성하려면 다음 예시를 참고한다. | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |||
! 마운트 지점 | ! 마운트 지점 | ||
! 권장 용도 | ! 권장 용도 | ||
! 예시 크기 | |||
|- | |||
| /boot/efi | |||
| UEFI 부트 영역 | |||
| 600 MiB | |||
|- | |||
| /boot | |||
| 커널 및 부트로더 | |||
| 1 GiB | |||
|- | |||
| / | |||
| 운영체제 루트 영역 | |||
| 40 GiB 이상 | |||
|- | |||
| /var | |||
| 로그 및 서비스 데이터 | |||
| 사용 목적에 따라 결정 | |||
|- | |||
| /home | |||
| 사용자 홈 디렉터리 | |||
| 사용 목적에 따라 결정 | |||
|- | |||
| swap | |||
| 메모리 보조 공간 | |||
| 메모리 및 용도에 따라 결정 | |||
|} | |||
로그 서버, DB 서버, 웹 서버는 /var 사용량이 크게 증가할 수 있으므로 | |||
별도 볼륨으로 분리하는 것이 좋다. | |||
로그 서버, DB 서버, 웹 서버는 | |||
=== 1.6 소프트웨어 선택 === | === 1.6 소프트웨어 선택 === | ||
| 159번째 줄: | 145번째 줄: | ||
Server with GUI | Server with GUI | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 1.7 root 비밀번호 및 사용자 생성 === | === 1.7 root 비밀번호 및 사용자 생성 === | ||
설치 과정에서 root 비밀번호를 | 설치 과정에서 root 비밀번호를 설정하고, | ||
관리용 일반 계정을 함께 생성하는 것을 권장한다. | |||
예시: | |||
예시 | |||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
| 174번째 줄: | 157번째 줄: | ||
관리자 권한: 활성화 | 관리자 권한: 활성화 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
설치 완료 후 시스템을 재부팅한다. | 설치 완료 후 시스템을 재부팅한다. | ||
| 185번째 줄: | 166번째 줄: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cat /etc/os-release | cat /etc/os-release | ||
uname -r | uname -r | ||
hostnamectl | hostnamectl | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| 220번째 줄: | 183번째 줄: | ||
=== 2.3 패키지 업데이트 === | === 2.3 패키지 업데이트 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 227번째 줄: | 188번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
커널이 업데이트되었으면 재부팅한다. | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
reboot | reboot | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| 243번째 줄: | 198번째 줄: | ||
Rocky Linux 9는 NetworkManager를 기본 네트워크 관리 서비스로 사용한다. | Rocky Linux 9는 NetworkManager를 기본 네트워크 관리 서비스로 사용한다. | ||
CLI에서는 주로 | CLI에서는 주로 nmcli 명령어를 사용한다. | ||
=== 3.1 네트워크 인터페이스 확인 === | === 3.1 네트워크 인터페이스 확인 === | ||
| 249번째 줄: | 204번째 줄: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ip address | ip address | ||
ip -br address | ip -br address | ||
nmcli device status | nmcli device status | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 3.2 네트워크 연결 프로파일 확인 === | === 3.2 네트워크 연결 프로파일 확인 === | ||
| 277번째 줄: | 212번째 줄: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection show | nmcli connection show | ||
</syntaxhighlight> | </syntaxhighlight> | ||
장치 이름과 연결 프로파일 이름은 다를 수 있다. | 장치 이름과 연결 프로파일 이름은 다를 수 있다. | ||
=== 3.3 DHCP 설정 === | === 3.3 DHCP 설정 === | ||
연결 프로파일 이름이 | 연결 프로파일 이름이 ens192인 경우: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 302번째 줄: | 228번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
확인: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ip -br address show ens192 | ip -br address show ens192 | ||
ip route | ip route | ||
cat /etc/resolv.conf | cat /etc/resolv.conf | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| 322번째 줄: | 238번째 줄: | ||
=== 3.4 고정 IP 설정 === | === 3.4 고정 IP 설정 === | ||
예시 환경: | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |||
! 항목 | ! 항목 | ||
! 설정값 | |||
|- | |||
| 연결 프로파일 | |||
| ens192 | |||
|- | |||
| IP 주소 | |||
| 192.168.10.20 | |||
|- | |||
| 서브넷 | |||
| /24 | |||
|- | |||
| 기본 게이트웨이 | |||
| 192.168.10.1 | |||
|- | |||
| DNS 서버 | |||
| 192.168.10.1, 8.8.8.8 | |||
|} | |||
설정: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 353번째 줄: | 269번째 줄: | ||
ipv4.gateway 192.168.10.1 \ | ipv4.gateway 192.168.10.1 \ | ||
ipv4.dns "192.168.10.1 8.8.8.8" | ipv4.dns "192.168.10.1 8.8.8.8" | ||
nmcli connection modify ens192 connection.autoconnect yes | nmcli connection modify ens192 connection.autoconnect yes | ||
nmcli connection up ens192 | nmcli connection up ens192 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| 372번째 줄: | 279번째 줄: | ||
=== 3.5 설정 결과 확인 === | === 3.5 설정 결과 확인 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ip -br address | ip -br address | ||
ip route | |||
ping -c 4 192.168.10.1 | |||
ping -c 4 8.8.8.8 | |||
ping -c 4 google.com | |||
</syntaxhighlight> | </syntaxhighlight> | ||
8.8.8.8 통신은 되지만 도메인 이름 통신이 되지 않으면 DNS 설정을 확인한다. | |||
=== 3.6 네트워크 설정 상세 확인 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection show ens192 | |||
nmcli -f ipv4 connection show ens192 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== 4. 네트워크 인터페이스 본딩 설정 == | |||
네트워크 본딩은 두 개 이상의 물리 인터페이스를 하나의 논리 인터페이스로 묶어 | |||
장애 절체 또는 부하 분산을 구성하는 기능이다. | |||
=== 4.1 본딩 설정 전 주의사항 === | |||
본딩 설정 중 네트워크가 중단될 수 있으므로 반드시 콘솔 접속 수단을 확보한다. | |||
기존 설정 백업: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
BACKUP_DIR="/root/network-backup-$(date +%Y%m%d_%H%M%S)" | |||
mkdir -p "$BACKUP_DIR" | |||
cp -a /etc/NetworkManager/system-connections "$BACKUP_DIR/" 2>/dev/null | |||
cp -a /etc/sysconfig/network-scripts "$BACKUP_DIR/" 2>/dev/null | |||
nmcli connection show > "$BACKUP_DIR/nmcli-connection.txt" | |||
ip address > "$BACKUP_DIR/ip-address.txt" | |||
ip route > "$BACKUP_DIR/ip-route.txt" | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 4.2 본딩 모드 종류 === | |||
{| class="wikitable" | |||
|- | |||
! 모드 | |||
! 이름 | |||
! 동작 방식 | |||
! 스위치 설정 | |||
! 권장 용도 | |||
|- | |||
| mode=0 | |||
| balance-rr | |||
| 패킷을 순차적으로 각 인터페이스에 전송 | |||
| 정적 포트 채널 필요 | |||
| 특수 부하 분산 | |||
|- | |||
| mode=1 | |||
| active-backup | |||
| 하나의 링크만 사용하고 장애 시 예비 링크로 전환 | |||
| 일반적으로 불필요 | |||
| 서버 이중화 | |||
|- | |||
| mode=2 | |||
| balance-xor | |||
| MAC 기반으로 송신 인터페이스 선택 | |||
| 정적 포트 채널 필요 | |||
| 고정 방식 부하 분산 | |||
|- | |||
| mode=3 | |||
| broadcast | |||
| 모든 링크로 동일 패킷 전송 | |||
| 환경에 따라 필요 | |||
| 특수 고가용성 | |||
|- | |||
| mode=4 | |||
| 802.3ad | |||
| LACP 기반 부하 분산 | |||
| LACP 포트 채널 필수 | |||
| 대역폭 확장 및 이중화 | |||
|- | |||
| mode=5 | |||
| balance-tlb | |||
| 송신 부하 분산 | |||
| 일반적으로 불필요 | |||
| 제한된 스위치 환경 | |||
|- | |||
| mode=6 | |||
| balance-alb | |||
| 송수신 부하 분산 | |||
| 일반적으로 불필요 | |||
| 제한된 스위치 환경 | |||
|} | |||
일반적인 서버에서는 active-backup 또는 802.3ad를 주로 사용한다. | |||
=== 4.3 구성 예시 === | |||
{| class="wikitable" | |||
|- | |||
! 항목 | |||
! 설정값 | |||
|- | |||
| 첫 번째 인터페이스 | |||
| ens192 | |||
|- | |||
| 두 번째 인터페이스 | |||
| ens224 | |||
|- | |||
| 본딩 인터페이스 | |||
| bond0 | |||
|- | |||
| 본딩 모드 | |||
| active-backup | |||
|- | |||
| IP 주소 | |||
| 192.168.10.20/24 | |||
|- | |||
| 기본 게이트웨이 | |||
| 192.168.10.1 | |||
|- | |||
| DNS 서버 | |||
| 192.168.10.1, 8.8.8.8 | |||
|- | |||
| 우선 인터페이스 | |||
| ens192 | |||
|} | |||
확인: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection show | ip -br link | ||
nmcli device status | |||
nmcli connection show | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 4.4 active-backup 본딩 생성 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli - | nmcli connection add \ | ||
type bond \ | |||
con-name bond0 \ | |||
ifname bond0 \ | |||
bond.options "mode=active-backup,miimon=100,primary=ens192" | |||
</syntaxhighlight> | </syntaxhighlight> | ||
첫 번째 포트 추가: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection add \ | |||
type ethernet \ | |||
con-name bond0-port1 \ | |||
ifname ens192 \ | |||
master bond0 \ | |||
slave-type bond | |||
</syntaxhighlight> | </syntaxhighlight> | ||
두 번째 포트 추가: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection add \ | |||
type ethernet \ | |||
con-name bond0-port2 \ | |||
ifname ens224 \ | |||
master bond0 \ | |||
slave-type bond | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 4. | === 4.5 bond0 고정 IP 설정 === | ||
<syntaxhighlight lang="bash"> | |||
nmcli connection modify bond0 \ | |||
ipv4.method manual \ | |||
ipv4.addresses 192.168.10.20/24 \ | |||
ipv4.gateway 192.168.10.1 \ | |||
ipv4.dns "192.168.10.1 8.8.8.8" \ | |||
ipv6.method disabled \ | |||
connection.autoconnect yes | |||
nmcli connection modify bond0-port1 connection.autoconnect yes | |||
nmcli connection modify bond0-port2 connection.autoconnect yes | |||
</syntaxhighlight> | </syntaxhighlight> | ||
지원되는 경우: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection modify bond0 connection.autoconnect-ports 1 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
구형 속성명만 지원하는 경우: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection modify bond0 connection.autoconnect-slaves 1 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 4.6 본딩 활성화 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection up bond0-port1 | |||
nmcli connection up bond0-port2 | |||
nmcli connection up bond0 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 4. | === 4.7 DHCP 본딩 설정 === | ||
<syntaxhighlight lang="bash"> | |||
nmcli connection modify bond0 \ | |||
ipv4.method auto \ | |||
ipv4.addresses "" \ | |||
ipv4.gateway "" \ | |||
ipv4.dns "" | |||
nmcli connection up bond0 | |||
</syntaxhighlight> | |||
=== 4.8 802.3ad LACP 본딩 설정 === | |||
먼저 | 스위치에서 LACP 포트 채널 구성이 먼저 완료되어 있어야 한다. | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection add \ | |||
type bond \ | |||
con-name bond0 \ | |||
ifname bond0 \ | |||
bond.options "mode=802.3ad,miimon=100,lacp_rate=fast,xmit_hash_policy=layer3+4" | |||
</syntaxhighlight> | </syntaxhighlight> | ||
포트 추가: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection add \ | |||
type ethernet \ | |||
con-name bond0-port1 \ | |||
ifname ens192 \ | |||
master bond0 \ | |||
slave-type bond | |||
nmcli connection add \ | |||
type ethernet \ | |||
con-name bond0-port2 \ | |||
ifname ens224 \ | |||
master bond0 \ | |||
slave-type bond | |||
</syntaxhighlight> | </syntaxhighlight> | ||
설정 | IP 설정: | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
nmcli connection modify bond0 \ | |||
ipv4.method manual \ | |||
192.168.10. | ipv4.addresses 192.168.10.20/24 \ | ||
ipv4.gateway 192.168.10.1 \ | |||
ipv4.dns "192.168.10.1 8.8.8.8" \ | |||
connection.autoconnect yes | |||
</syntaxhighlight> | </syntaxhighlight> | ||
활성화: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection up bond0-port1 | |||
nmcli connection up bond0-port2 | |||
nmcli connection up bond0 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== | 단일 TCP 세션 하나의 속도가 물리 링크 합산 속도로 증가하는 방식은 아니다. | ||
=== 4.9 본딩 상태 확인 === | |||
<syntaxhighlight lang="bash"> | |||
nmcli device status | |||
nmcli connection show | |||
ip -br address show bond0 | |||
cat /proc/net/bonding/bond0 | |||
</syntaxhighlight> | |||
주요 확인 항목: | |||
=== | {| class="wikitable" | ||
|- | |||
! 항목 | |||
! 확인 내용 | |||
|- | |||
| Bonding Mode | |||
| 설정한 본딩 모드 | |||
|- | |||
| Currently Active Slave | |||
| 현재 활성 인터페이스 | |||
|- | |||
| MII Status | |||
| 물리 링크 up/down 상태 | |||
|- | |||
| Slave Interface | |||
| 본딩 포함 인터페이스 | |||
|- | |||
| Link Failure Count | |||
| 링크 장애 횟수 | |||
|- | |||
| Aggregator ID | |||
| LACP 링크가 같은 Aggregator인지 확인 | |||
|} | |||
=== 4.10 active-backup 절체 테스트 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
grep "Currently Active Slave" /proc/net/bonding/bond0 | |||
ping 192.168.10.1 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
다른 콘솔에서 활성 인터페이스를 내린다. | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ip link set ens192 down | |||
</syntaxhighlight> | </syntaxhighlight> | ||
절체 확인: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
grep "Currently Active Slave" /proc/net/bonding/bond0 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
복구: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ip link set ens192 up | |||
nmcli device status | |||
cat /proc/net/bonding/bond0 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 4.11 물리 링크 확인 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ethtool ens192 | grep -E 'Speed|Duplex|Link detected' | |||
ethtool ens224 | grep -E 'Speed|Duplex|Link detected' | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== 5. 구형 ifcfg 파일 형식 적용 == | |||
일부 구형 콜서버, PBX, CTI 또는 제조사 애플리케이션은 | |||
다음 경로의 설정 파일을 직접 확인하는 경우가 있다. | |||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
/etc/sysconfig/network-scripts/ifcfg-bond0 | |||
/etc/sysconfig/network-scripts/ifcfg-ens192 | |||
/etc/sysconfig/network-scripts/ifcfg-ens224 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Rocky Linux 9에서는 ifcfg 파일을 사용하더라도 실제 네트워크 제어는 NetworkManager가 수행한다. | |||
NetworkManager를 비활성화하고 구형 network 서비스를 활성화하는 방식은 사용하지 않는다. | |||
=== 5.1 현재 프로파일 저장 위치 확인 === | |||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
nmcli -f NAME,UUID,TYPE,DEVICE,FILENAME connection show | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 5.2 ifcfg-rh 플러그인 확인 === | |||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
NetworkManager --version | |||
nmcli --version | |||
find /usr/lib64/NetworkManager /usr/lib/NetworkManager \ | |||
-type f -iname '*ifcfg*' 2>/dev/null | |||
rpm -qa | grep -E '^NetworkManager|ifcfg' | |||
nmcli connection help | grep -A5 migrate | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 5. | === 5.3 keyfile을 ifcfg 형식으로 변환 === | ||
변환 전 백업: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
BACKUP_DIR="/root/network-profile-backup-$(date +%Y%m%d_%H%M%S)" | |||
mkdir -p "$BACKUP_DIR" | |||
cp -a /etc/NetworkManager/system-connections "$BACKUP_DIR/" | |||
cp -a /etc/sysconfig/network-scripts "$BACKUP_DIR/" 2>/dev/null | |||
</syntaxhighlight> | </syntaxhighlight> | ||
변환: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection migrate --plugin ifcfg-rh id bond0 | |||
nmcli connection migrate --plugin ifcfg-rh id bond0-port1 | |||
nmcli connection migrate --plugin ifcfg-rh id bond0-port2 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
결과 확인: | |||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
nmcli -f NAME,TYPE,DEVICE,FILENAME connection show | |||
ls -l /etc/sysconfig/network-scripts/ifcfg-* | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 5.4 실제 인터페이스명 파일이 필요한 경우 === | |||
일부 프로그램은 다음 파일명을 요구할 수 있다. | |||
<syntaxhighlight lang="text"> | |||
ifcfg-ens192 | |||
ifcfg-ens224 | |||
</syntaxhighlight> | |||
프로파일 이름 변경: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection modify bond0-port1 connection.id ens192 | |||
nmcli connection modify bond0-port2 connection.id ens224 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
다시 변환: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli connection migrate --plugin ifcfg-rh id ens192 | |||
nmcli connection migrate --plugin ifcfg-rh id ens224 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
확인: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli -f NAME,DEVICE,FILENAME connection show | |||
ls -l /etc/sysconfig/network-scripts/ifcfg-* | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 5.5 ifcfg-bond0 예시 === | |||
<syntaxhighlight lang="ini"> | |||
TYPE=Bond | |||
BONDING_MASTER=yes | |||
NAME=bond0 | |||
DEVICE=bond0 | |||
ONBOOT=yes | |||
BOOTPROTO=none | |||
IPADDR=192.168.10.20 | |||
PREFIX=24 | |||
GATEWAY=192.168.10.1 | |||
DNS1=192.168.10.1 | |||
DNS2=8.8.8.8 | |||
BONDING_OPTS="mode=active-backup miimon=100 primary=ens192" | |||
IPV6INIT=no | |||
</syntaxhighlight> | |||
== 6 | === 5.6 ifcfg-ens192 예시 === | ||
=== | <syntaxhighlight lang="ini"> | ||
TYPE=Ethernet | |||
NAME=ens192 | |||
DEVICE=ens192 | |||
ONBOOT=yes | |||
BOOTPROTO=none | |||
MASTER=bond0 | |||
SLAVE=yes | |||
</syntaxhighlight> | |||
예시 | === 5.7 ifcfg-ens224 예시 === | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="ini"> | ||
TYPE=Ethernet | |||
NAME=ens224 | |||
DEVICE=ens224 | |||
ONBOOT=yes | |||
BOOTPROTO=none | |||
MASTER=bond0 | |||
SLAVE=yes | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 5.8 ifcfg 파일 직접 작성 === | |||
기존 설정 백업: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cp -a /etc/sysconfig/network-scripts \ | |||
/root/network-scripts-backup-$(date +%Y%m%d_%H%M%S) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
파일 작성 후 권한 설정: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
chmod 600 /etc/sysconfig/network-scripts/ifcfg-bond0 | |||
chmod 600 /etc/sysconfig/network-scripts/ifcfg-ens192 | |||
chmod 600 /etc/sysconfig/network-scripts/ifcfg-ens224 | |||
nmcli connection reload | |||
nmcli -f NAME,DEVICE,TYPE,FILENAME connection show | |||
</syntaxhighlight> | </syntaxhighlight> | ||
동일 장치의 keyfile과 ifcfg 파일이 함께 존재하면 중복 프로파일이 생성될 수 있다. | |||
=== 5.9 중복 프로파일 확인 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nmcli -f NAME,UUID,DEVICE,TYPE,FILENAME connection show | |||
</syntaxhighlight> | </syntaxhighlight> | ||
사용하지 않는 프로파일 삭제: | |||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
nmcli connection delete 사용하지_않는_프로파일명 | |||
nmcli connection reload | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 5.10 keyfile 형식으로 복원 === | |||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
cp -a /etc/sysconfig/network-scripts \ | |||
/root/ifcfg-backup-$(date +%Y%m%d_%H%M%S) | |||
nmcli connection migrate --plugin keyfile id bond0 | |||
nmcli connection migrate --plugin keyfile id ens192 | |||
nmcli connection migrate --plugin keyfile id ens224 | |||
nmcli -f NAME,DEVICE,TYPE,FILENAME connection show | |||
nmcli connection reload | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== 6. 호스트 이름 설정 == | |||
현재 | === 6.1 현재 호스트 이름 확인 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
hostname | |||
hostnamectl | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 6.2 호스트 이름 변경 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
hostnamectl set-hostname rocky-file01 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
FQDN 형식: | |||
<syntaxhighlight lang="bash"> | |||
hostnamectl set-hostname rocky-file01.example.local | |||
</syntaxhighlight> | |||
확인: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
hostnamectl | |||
hostname | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 6.3 /etc/hosts 등록 === | |||
백업: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cp -a /etc/hosts /etc/hosts.bak.$(date +%Y%m%d_%H%M%S) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
편집: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
vi /etc/hosts | |||
</syntaxhighlight> | </syntaxhighlight> | ||
예시: | |||
<syntaxhighlight lang=" | <syntaxhighlight lang="text"> | ||
127.0.0.1 localhost localhost.localdomain | |||
::1 localhost localhost.localdomain | |||
192.168.10.20 rocky-file01.example.local rocky-file01 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
확인: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
getent hosts rocky-file01 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== 7. SSH 기본 설정 == | |||
=== 7.1 SSH 서버 설치 확인 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
rpm -q openssh-server | |||
</syntaxhighlight> | </syntaxhighlight> | ||
미설치 시: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
dnf install -y openssh-server | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 7. | === 7.2 SSH 서비스 시작 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl enable --now sshd | |||
systemctl status sshd | |||
systemctl is-active sshd | |||
systemctl is-enabled sshd | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 7.3 설정 파일 백업 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cp -a /etc/ssh/sshd_config \ | |||
/etc/ssh/sshd_config.bak.$(date +%Y%m%d_%H%M%S) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
추가 설정 파일 생성: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
vi /etc/ssh/sshd_config.d/10-custom.conf | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 7.4 | === 7.4 기본 보안 설정 예시 === | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="apache"> | ||
PermitRootLogin no | |||
MaxAuthTries 5 | |||
LoginGraceTime 60 | |||
X11Forwarding no | |||
</syntaxhighlight> | </syntaxhighlight> | ||
문법 검사: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sshd -t | |||
</syntaxhighlight> | </syntaxhighlight> | ||
설정 적용: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl reload sshd | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== | 기존 SSH 세션을 닫기 전에 새 터미널에서 접속 성공 여부를 확인한다. | ||
== 8. SSH 접속 계정 제한 == | |||
=== 8.1 관리 계정 생성 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
useradd admin | |||
passwd admin | |||
usermod -aG wheel admin | |||
id admin | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 8.2 특정 계정만 접속 허용 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
vi /etc/ssh/sshd_config.d/10-custom.conf | |||
</syntaxhighlight> | </syntaxhighlight> | ||
설정: | |||
<syntaxhighlight lang=" | <syntaxhighlight lang="apache"> | ||
AllowUsers admin | |||
</syntaxhighlight> | </syntaxhighlight> | ||
여러 계정: | |||
= | <syntaxhighlight lang="apache"> | ||
AllowUsers admin operator backupuser | |||
</syntaxhighlight> | |||
그룹 기준: | |||
<syntaxhighlight lang="apache"> | |||
AllowGroups wheel | |||
</syntaxhighlight> | |||
문법 검사 및 적용: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl | sshd -t | ||
systemctl reload sshd | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== 9. SSH 포트 변경 == | |||
예시로 SSH 포트를 2222번으로 변경한다. | |||
=== 9.1 SSH 설정 변경 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
vi /etc/ssh/sshd_config.d/10-custom.conf | |||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="apache"> | |||
Port 2222 | |||
<syntaxhighlight lang=" | |||
</syntaxhighlight> | </syntaxhighlight> | ||
문법 검사: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sshd -t | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 9.2 SELinux 포트 등록 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
dnf install -y policycoreutils-python-utils | |||
semanage port -l | grep ssh | |||
semanage port -a -t ssh_port_t -p tcp 2222 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
이미 등록된 포트라면: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
semanage port -m -t ssh_port_t -p tcp 2222 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 9.3 firewalld 포트 허용 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
firewall-cmd --permanent --add- | firewall-cmd --permanent --add-port=2222/tcp | ||
firewall-cmd --reload | firewall-cmd --reload | ||
firewall-cmd --list-ports | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 9.4 SSH 재시작 및 확인 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl restart sshd | |||
systemctl status sshd | |||
ss -lntp | grep 2222 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
새 포트 접속 테스트: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ssh -p 2222 admin@192.168.10.20 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
정상 접속 후 기존 22번 허용 제거: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
firewall-cmd --permanent -- | firewall-cmd --permanent --remove-service=ssh | ||
firewall-cmd --reload | firewall-cmd --reload | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == 10. firewalld 기본 사용법 == | ||
=== 10.1 상태 확인 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl status firewalld | |||
systemctl is-active firewalld | |||
systemctl is-enabled firewalld | |||
</syntaxhighlight> | </syntaxhighlight> | ||
시작: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl enable --now firewalld | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 10.2 존 및 설정 확인 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
firewall-cmd -- | firewall-cmd --get-active-zones | ||
firewall-cmd -- | firewall-cmd --get-default-zone | ||
firewall-cmd -- | firewall-cmd --list-all | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 10.3 서비스 허용 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
firewall-cmd --permanent -- | firewall-cmd --permanent --add-service=ssh | ||
firewall-cmd --permanent --add-service=http | |||
firewall-cmd --permanent --add-service=https | |||
firewall-cmd --permanent --add-service=samba | |||
firewall-cmd --reload | firewall-cmd --reload | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 10.4 포트 번호 허용 === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
firewall-cmd --permanent -- | firewall-cmd --permanent --add-port=8080/tcp | ||
firewall-cmd --permanent --add-port=514/tcp | |||
firewall-cmd --permanent --add-port=514/udp | |||
firewall-cmd --reload | firewall-cmd --reload | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 10.5 허용 설정 제거 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
firewall-cmd -- | firewall-cmd --permanent --remove-port=8080/tcp | ||
firewall-cmd --permanent --remove-service=http | |||
firewall-cmd --permanent -- | |||
firewall-cmd --reload | firewall-cmd --reload | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 10.6 특정 IP 대역만 SSH 허용 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
firewall-cmd --permanent \ | firewall-cmd --permanent \ | ||
--add-rich-rule='rule family="ipv4" source address="192.168.10.0/24" port port="22" protocol="tcp" accept' | --add-rich-rule='rule family="ipv4" source address="192.168.10.0/24" port port="22" protocol="tcp" accept' | ||
firewall-cmd --permanent --remove-service=ssh | firewall-cmd --permanent --remove-service=ssh | ||
firewall-cmd --reload | firewall-cmd --reload | ||
firewall-cmd --list-rich-rules | firewall-cmd --list-rich-rules | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == 11. firewalld 비활성화 및 iptables 전환 == | ||
Rocky Linux 9에서는 firewalld 사용을 우선 권장한다. | Rocky Linux 9에서는 firewalld 사용을 우선 권장한다. | ||
기존 운영 환경이 iptables 규칙으로 표준화된 경우에만 전환을 고려한다. | |||
=== | === 11.1 기존 방화벽 규칙 백업 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
firewall-cmd --list-all-zones > /root/firewalld-backup-$(date +%Y%m%d_%H%M%S).txt | firewall-cmd --list-all-zones > /root/firewalld-backup-$(date +%Y%m%d_%H%M%S).txt | ||
nft list ruleset > /root/nftables-backup-$(date +%Y%m%d_%H%M%S).txt | nft list ruleset > /root/nftables-backup-$(date +%Y%m%d_%H%M%S).txt | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 11.2 iptables 서비스 설치 === | |||
=== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
dnf install -y iptables-services | dnf install -y iptables-services | ||
rpm -q iptables-services | rpm -q iptables-services | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 11.3 firewalld 비활성화 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl disable --now firewalld | systemctl disable --now firewalld | ||
systemctl is-active firewalld | systemctl is-active firewalld | ||
systemctl is-enabled firewalld | systemctl is-enabled firewalld | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 11.4 iptables 기본 규칙 작성 === | |||
== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 1,050번째 줄: | 1,113번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
예시: | |||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
| 1,060번째 줄: | 1,123번째 줄: | ||
-A INPUT -i lo -j ACCEPT | -A INPUT -i lo -j ACCEPT | ||
-A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT | -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT | ||
-A INPUT -p icmp -j ACCEPT | -A INPUT -p icmp -j ACCEPT | ||
| 1,072번째 줄: | 1,134번째 줄: | ||
-A INPUT -m conntrack --ctstate INVALID -j DROP | -A INPUT -m conntrack --ctstate INVALID -j DROP | ||
COMMIT </syntaxhighlight> | COMMIT | ||
</syntaxhighlight> | |||
SSH 포트를 2222번으로 | SSH 포트를 2222번으로 변경했다면 다음과 같이 수정한다. | ||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
| 1,080번째 줄: | 1,143번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 11.5 iptables 서비스 시작 === | |||
=== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl enable --now iptables | systemctl enable --now iptables | ||
systemctl status iptables | systemctl status iptables | ||
iptables -L -n -v --line-numbers | iptables -L -n -v --line-numbers | ||
service iptables save | service iptables save | ||
</syntaxhighlight> | </syntaxhighlight> | ||
또는 | 또는: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 1,112번째 줄: | 1,158번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == 12. 서비스 정상 유무 확인 == | ||
=== | === 12.1 systemctl 확인 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl status sshd | systemctl status sshd | ||
systemctl status smb | systemctl status smb | ||
systemctl status nmb | systemctl status nmb | ||
systemctl is-active sshd | systemctl is-active sshd | ||
systemctl is-active smb | systemctl is-active smb | ||
systemctl is-enabled sshd | systemctl is-enabled sshd | ||
systemctl is-enabled smb | systemctl is-enabled smb | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 12.2 실패한 서비스 확인 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl --failed | systemctl --failed | ||
journalctl -u sshd -n 50 --no-pager | journalctl -u sshd -n 50 --no-pager | ||
journalctl -u smb -n 50 --no-pager | journalctl -u smb -n 50 --no-pager | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 12.3 설정 문법 검사 === | |||
== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sshd -t | sshd -t | ||
testparm | testparm | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == 13. 서비스 포트 리스닝 확인 == | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ss -lntup | ss -lntup | ||
ss -lntp | ss -lntp | ||
ss -lnup | ss -lnup | ||
ss -lntp | grep ':22' | ss -lntp | grep ':22' | ||
ss -lntp | grep ':2222' | ss -lntp | grep ':2222' | ||
ss -lntup | grep -E ':137|:138|:139|:445' | ss -lntup | grep -E ':137|:138|:139|:445' | ||
</syntaxhighlight> | </syntaxhighlight> | ||
확인 항목: | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |||
! 항목 | ! 항목 | ||
! 설명 | |||
|- | |||
| LISTEN | |||
| 연결 대기 상태 | |||
|- | |||
| 0.0.0.0:22 | |||
| 모든 IPv4 인터페이스에서 수신 | |||
|- | |||
| [::]:22 | |||
| 모든 IPv6 인터페이스에서 수신 | |||
|- | |||
| 127.0.0.1 | |||
| 로컬 서버에서만 접근 가능 | |||
|- | |||
| users | |||
| 해당 포트를 사용하는 프로세스 | |||
|} | |||
== 14. 외부에서 포트 오픈 여부 확인 == | |||
=== 14.1 Linux에서 nc 사용 === | |||
== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
dnf install -y nmap-ncat | dnf install -y nmap-ncat | ||
nc -zv 192.168.10.20 22 | nc -zv 192.168.10.20 22 | ||
nc -zv 192.168.10.20 2222 | nc -zv 192.168.10.20 2222 | ||
nc -zv 192.168.10.20 445 | nc -zv 192.168.10.20 445 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 14.2 Windows PowerShell에서 확인 === | |||
=== | |||
<syntaxhighlight lang="powershell"> | <syntaxhighlight lang="powershell"> | ||
Test-NetConnection 192.168.10.20 -Port 22 | Test-NetConnection 192.168.10.20 -Port 22 | ||
Test-NetConnection 192.168.10.20 -Port 2222 | Test-NetConnection 192.168.10.20 -Port 2222 | ||
Test-NetConnection 192.168.10.20 -Port 445 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== 15. SSH 접속 테스트 == | |||
= | |||
기본 포트: | 기본 포트: | ||
| 1,365번째 줄: | 1,256번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
SSH 장애 확인 순서: | |||
# 서버 IP 통신 확인 | # 서버 IP 통신 확인 | ||
# SSH 서비스 상태 확인 | # SSH 서비스 상태 확인 | ||
# SSH 설정 문법 확인 | # SSH 설정 문법 확인 | ||
# SSH 포트 리스닝 확인 | # SSH 포트 리스닝 확인 | ||
# 방화벽 규칙 확인 | |||
# | |||
# SELinux 포트 등록 확인 | # SELinux 포트 등록 확인 | ||
# SSH 로그 확인 | |||
# | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 1,436번째 줄: | 1,276번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == 16. SFTP 접속 테스트 == | ||
SFTP는 SSH 서비스를 사용하며 별도 FTP 서버가 필요하지 않다. | |||
기본 포트: | 기본 포트: | ||
| 1,460번째 줄: | 1,292번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
주요 명령: | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |||
! 명령어 | ! 명령어 | ||
! 설명 | |||
|- | |||
| pwd | |||
| 서버 현재 디렉터리 | |||
|- | |||
| lpwd | |||
| 로컬 현재 디렉터리 | |||
|- | |||
| ls | |||
| 서버 파일 목록 | |||
|- | |||
| lls | |||
| 로컬 파일 목록 | |||
|- | |||
| get 파일명 | |||
| 파일 다운로드 | |||
|- | |||
| put 파일명 | |||
| 파일 업로드 | |||
|- | |||
| exit | |||
| 종료 | |||
|} | |||
FileZilla 설정: | |||
FileZilla | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |||
! 항목 | ! 항목 | ||
! 설정값 | |||
|- | |||
| 프로토콜 | |||
| SFTP - SSH File Transfer Protocol | |||
|- | |||
| 호스트 | |||
| 192.168.10.20 | |||
|- | |||
| 포트 | |||
| 22 또는 변경한 SSH 포트 | |||
|- | |||
| 사용자 | |||
| admin | |||
|- | |||
| 비밀번호 | |||
| 해당 계정 비밀번호 | |||
|} | |||
== 17. Samba 파일 공유 설정 == | |||
== | |||
파일 | |||
=== 17.1 Samba 설치 === | |||
=== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
dnf install -y samba samba-client | dnf install -y samba samba-client | ||
rpm -q samba | rpm -q samba | ||
rpm -q samba-client | rpm -q samba-client | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 17.2 공유 계정 생성 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
useradd -m shareuser | useradd -m shareuser | ||
passwd shareuser | passwd shareuser | ||
smbpasswd -a shareuser | smbpasswd -a shareuser | ||
smbpasswd -e shareuser | smbpasswd -e shareuser | ||
pdbedit -L | pdbedit -L | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 17.3 공유 디렉터리 생성 === | |||
=== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
mkdir -p /data/share | mkdir -p /data/share | ||
chown -R shareuser:shareuser /data/share | chown -R shareuser:shareuser /data/share | ||
chmod 2770 /data/share | chmod 2770 /data/share | ||
ls -ld /data/share | ls -ld /data/share | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 17.4 Samba 설정 백업 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 1,642번째 줄: | 1,380번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 17.5 Samba 설정 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
vi /etc/samba/smb.conf | vi /etc/samba/smb.conf | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="ini"> | <syntaxhighlight lang="ini"> | ||
| 1,661번째 줄: | 1,395번째 줄: | ||
[share] | [share] | ||
comment = Shared Folder | comment = Shared Folder | ||
path = /data/share | path = /data/share | ||
browseable = yes | browseable = yes | ||
writable = yes | writable = yes | ||
read only = no | read only = no | ||
valid users = shareuser | valid users = shareuser | ||
create mask = 0660 | create mask = 0660 | ||
directory mask = 0770 </syntaxhighlight> | directory mask = 0770 | ||
</syntaxhighlight> | |||
문법 검사: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 1,711번째 줄: | 1,411번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 17.6 SELinux 설정 === | |||
=== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
dnf install -y policycoreutils-python-utils | dnf install -y policycoreutils-python-utils | ||
semanage fcontext -a -t samba_share_t "/data/share(/.*)?" | semanage fcontext -a -t samba_share_t "/data/share(/.*)?" | ||
restorecon -Rv /data/share | restorecon -Rv /data/share | ||
ls -ldZ /data/share | ls -ldZ /data/share | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 17.7 Samba 서비스 시작 === | |||
=== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl enable --now smb | systemctl enable --now smb | ||
systemctl enable --now nmb | systemctl enable --now nmb | ||
systemctl status smb | systemctl status smb | ||
systemctl status nmb | systemctl status nmb | ||
</syntaxhighlight> | </syntaxhighlight> | ||
최신 Windows 환경에서 IP 주소 또는 DNS 이름으로 직접 접근하는 경우 | 최신 Windows 환경에서 IP 주소 또는 DNS 이름으로 직접 접근하는 경우 | ||
smb 서비스만으로도 동작할 수 있다. | |||
=== | === 17.8 방화벽 허용 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
firewall-cmd --permanent --add-service=samba | firewall-cmd --permanent --add-service=samba | ||
firewall-cmd --reload | firewall-cmd --reload | ||
firewall-cmd --list-services | firewall-cmd --list-services | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 17.9 Samba 포트 확인 === | |||
= | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ss -lntup | grep -E ':137|:138|:139|:445' | ss -lntup | grep -E ':137|:138|:139|:445' | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |||
! 포트 | ! 포트 | ||
! 프로토콜 | ! 프로토콜 | ||
! 용도 | |||
|- | |||
| 137 | |||
| UDP | |||
| NetBIOS 이름 서비스 | |||
|- | |||
| 138 | |||
| UDP | |||
| NetBIOS 데이터그램 | |||
|- | |||
| 139 | |||
| TCP | |||
| NetBIOS 세션 서비스 | |||
|- | |||
| 445 | |||
| TCP | |||
| SMB 직접 통신 | |||
|} | |||
=== 17.10 서버 내부 테스트 === | |||
=== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
smbclient -L localhost -U shareuser | smbclient -L localhost -U shareuser | ||
smbclient //localhost/share -U shareuser | smbclient //localhost/share -U shareuser | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 17.11 Windows에서 접속 === | |||
== | |||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
| 1,871번째 줄: | 1,484번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
호스트 이름으로 | 호스트 이름으로 접근: | ||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
| 1,877번째 줄: | 1,490번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Windows 자격 증명 초기화: | |||
<syntaxhighlight lang="batch"> | <syntaxhighlight lang="batch"> | ||
| 1,904번째 줄: | 1,496번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
네트워크 드라이브 연결: | |||
<syntaxhighlight lang="batch"> | <syntaxhighlight lang="batch"> | ||
| 1,916번째 줄: | 1,502번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 17.12 Samba 장애 확인 순서 === | ||
# 서버 IP 통신 확인 | |||
# smb 서비스 상태 확인 | # smb 서비스 상태 확인 | ||
# TCP 445 포트 리스닝 확인 | # TCP 445 포트 리스닝 확인 | ||
# 방화벽 허용 확인 | # 방화벽 허용 확인 | ||
# Samba 설정 문법 확인 | # Samba 설정 문법 확인 | ||
# Samba 계정 확인 | |||
# Samba 계정 | |||
# Linux 디렉터리 권한 확인 | # Linux 디렉터리 권한 확인 | ||
# SELinux 컨텍스트 확인 | # SELinux 컨텍스트 확인 | ||
# Samba 로그 확인 | # Samba 로그 확인 | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 1,948번째 줄: | 1,524번째 줄: | ||
ls -ldZ /data/share | ls -ldZ /data/share | ||
journalctl -u smb -n 100 --no-pager | journalctl -u smb -n 100 --no-pager | ||
ausearch -m AVC -ts recent | ausearch -m AVC -ts recent | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 18. 전체 설정 최종 점검 == | |||
= | |||
=== | === 18.1 시스템 정보 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 1,974번째 줄: | 1,537번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 18.2 네트워크 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 1,984번째 줄: | 1,547번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | 본딩 사용 시: | ||
<syntaxhighlight lang="bash"> | |||
cat /proc/net/bonding/bond0 | |||
nmcli -f NAME,UUID,DEVICE,TYPE,FILENAME connection show | |||
</syntaxhighlight> | |||
=== 18.3 SSH === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 1,994번째 줄: | 1,564번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 18.4 방화벽 === | ||
firewalld 사용 시: | firewalld 사용 시: | ||
| 2,012번째 줄: | 1,582번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 18.5 Samba === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 2,023번째 줄: | 1,593번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == 19. 구축 완료 후 권장 사항 == | ||
=== | === 19.1 root 원격 로그인 차단 === | ||
<syntaxhighlight lang="apache"> | <syntaxhighlight lang="apache"> | ||
| 2,031번째 줄: | 1,601번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 19.2 관리자 계정 사용 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 2,039번째 줄: | 1,607번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 19.3 불필요한 서비스 비활성화 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl --type=service --state=running | systemctl --type=service --state=running | ||
systemctl disable --now 서비스명 | systemctl disable --now 서비스명 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 19.4 정기 업데이트 === | |||
=== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
dnf check-update | dnf check-update | ||
dnf update -y | dnf update -y | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 19.5 시간 동기화 확인 === | |||
=== | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 2,079번째 줄: | 1,629번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
서울 시간대 설정: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 2,085번째 줄: | 1,635번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | === 19.6 주요 설정 백업 === | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
tar czvf /root/rocky-basic-config-$(date +%Y%m%d).tar.gz \ | tar czvf /root/rocky-basic-config-$(date +%Y%m%d).tar.gz \ | ||
/etc/NetworkManager/system-connections \ | /etc/NetworkManager/system-connections \ | ||
/etc/sysconfig/network-scripts \ | |||
/etc/hosts \ | /etc/hosts \ | ||
/etc/hostname \ | /etc/hostname \ | ||
| 2,113번째 줄: | 1,649번째 줄: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == 20. 전체 작업 순서 요약 == | ||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
| 2,119번째 줄: | 1,655번째 줄: | ||
2. 설치 후 패키지 업데이트 | 2. 설치 후 패키지 업데이트 | ||
3. 네트워크 인터페이스 확인 | 3. 네트워크 인터페이스 확인 | ||
4. 고정 IP 및 DNS 설정 | 4. 단일 NIC 또는 본딩 구성 | ||
5. 고정 IP 및 DNS 설정 | |||
6. 필요 시 ifcfg 형식으로 변환 | |||
7. 게이트웨이와 외부 통신 확인 | |||
8. 호스트 이름 설정 | |||
9. 관리자 계정 생성 | |||
10. SSH 서비스 확인 | |||
11. root 직접 로그인 차단 | |||
12. 필요 시 SSH 허용 계정 제한 | |||
13. 필요 시 SSH 포트 변경 | |||
14. SELinux에 변경 포트 등록 | |||
15. 방화벽 포트 허용 | |||
16. SSH와 SFTP 접속 테스트 | |||
17. Samba 패키지 설치 | |||
18. Samba 계정 및 공유 디렉터리 생성 | |||
19. Samba 설정 파일 작성 | |||
20. SELinux 컨텍스트 설정 | |||
21. Samba 방화벽 허용 | |||
22. Windows에서 공유 접속 테스트 | |||
23. 전체 설정 파일 백업 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == 21. 빠른 점검 명령어 모음 == | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| 2,146번째 줄: | 1,684번째 줄: | ||
# 호스트 이름 | # 호스트 이름 | ||
hostnamectl | hostnamectl | ||
# IP 주소 | # IP 주소 | ||
ip -br address | ip -br address | ||
# 라우팅 | # 라우팅 | ||
ip route | ip route | ||
# NetworkManager | # NetworkManager | ||
nmcli device status | nmcli device status | ||
nmcli connection show | nmcli connection show | ||
# 본딩 | |||
cat /proc/net/bonding/bond0 | |||
# SSH 상태 | # SSH 상태 | ||
systemctl status sshd | systemctl status sshd | ||
# SSH 문법 | # SSH 문법 | ||
sshd -t | sshd -t | ||
# 포트 리스닝 | # 포트 리스닝 | ||
ss -lntup | ss -lntup | ||
# firewalld | # firewalld | ||
firewall-cmd --list-all | firewall-cmd --list-all | ||
# iptables | # iptables | ||
iptables -L -n -v --line-numbers | iptables -L -n -v --line-numbers | ||
# Samba 문법 | # Samba 문법 | ||
testparm | testparm | ||
# Samba 계정 | # Samba 계정 | ||
pdbedit -L | pdbedit -L | ||
# Samba 서비스 | # Samba 서비스 | ||
systemctl status smb | systemctl status smb | ||
# 실패한 서비스 | # 실패한 서비스 | ||
systemctl --failed | systemctl --failed | ||
# 최근 부팅 | # 최근 부팅 오류 | ||
journalctl -p err -b --no-pager | |||
journalctl -p err -b --no-pager </syntaxhighlight> | </syntaxhighlight> | ||
== 관련 문서 == | == 관련 문서 == | ||
2026년 7월 10일 (금) 23:54 기준 최신판
Rocky Linux 9 초기 설치 및 기본 서버 설정 가이드
문서 개요
본 문서는 Rocky Linux 9 또는 RHEL 9 계열 운영체제를 처음 설치한 후 기본 서버로 사용하기 위한 초기 설정 절차를 단계별로 설명한다.
다음 순서로 진행한다.
- 운영체제 설치
- 설치 직후 기본 확인
- CLI에서 IP 주소 설정
- 네트워크 인터페이스 본딩 설정
- 구형 ifcfg 파일 형식 적용
- 호스트 이름 설정
- SSH 기본 설정
- SSH 특정 계정 접속 제한
- SSH 포트 변경
- firewalld 포트 허용
- firewalld 비활성화 및 iptables 전환
- 서비스 상태 및 포트 확인
- SSH 및 SFTP 접속 테스트
- Samba 파일 공유 설정
- 전체 설정 최종 점검
본 문서의 명령어는 기본적으로 root 계정으로 실행하는 것을 기준으로 한다.
일반 계정으로 실행할 경우 명령어 앞에 sudo를 추가한다.
sudo 명령어
1. 운영체제 설치
1.1 설치 이미지 준비
Rocky Linux 설치 이미지는 일반적으로 다음 두 종류를 사용한다.
| 이미지 종류 | 설명 | 권장 용도 |
|---|---|---|
| DVD ISO | 운영체제 설치에 필요한 대부분의 패키지가 포함되어 있다. | 인터넷 연결이 제한된 환경 |
| Boot ISO | 최소 설치 이미지이며 설치 중 인터넷 저장소에 연결한다. | 인터넷 연결이 가능한 환경 |
서버 환경에서는 일반적으로 DVD ISO 사용을 권장한다.
1.2 설치 USB 제작
Windows 환경에서는 Rufus, Ventoy 등의 프로그램을 사용하여 설치 USB를 만들 수 있다.
설치 대상 디스크의 기존 데이터는 모두 삭제될 수 있으므로 설치 전에 반드시 필요한 자료를 백업한다.
1.3 BIOS 또는 UEFI 설정
| 항목 | 권장 설정 |
|---|---|
| Boot Mode | UEFI |
| Secure Boot | 일반적으로 활성화 가능 |
| SATA Mode | AHCI |
| Virtualization | 가상화 사용 시 활성화 |
| Boot Priority | USB 설치 장치를 첫 번째로 설정 |
1.4 설치 화면 진입
설치 USB 또는 ISO로 부팅한 후 다음 항목을 선택한다.
Install Rocky Linux 9
1.5 설치 대상 디스크 설정
초심자는 자동 파티션 구성을 사용할 수 있다.
서버 용도로 별도 파티션을 구성하려면 다음 예시를 참고한다.
| 마운트 지점 | 권장 용도 | 예시 크기 |
|---|---|---|
| /boot/efi | UEFI 부트 영역 | 600 MiB |
| /boot | 커널 및 부트로더 | 1 GiB |
| / | 운영체제 루트 영역 | 40 GiB 이상 |
| /var | 로그 및 서비스 데이터 | 사용 목적에 따라 결정 |
| /home | 사용자 홈 디렉터리 | 사용 목적에 따라 결정 |
| swap | 메모리 보조 공간 | 메모리 및 용도에 따라 결정 |
로그 서버, DB 서버, 웹 서버는 /var 사용량이 크게 증가할 수 있으므로 별도 볼륨으로 분리하는 것이 좋다.
1.6 소프트웨어 선택
서버 용도에서는 다음 설치 유형을 권장한다.
Minimal Install
GUI가 필요한 경우 다음을 선택할 수 있다.
Server with GUI
1.7 root 비밀번호 및 사용자 생성
설치 과정에서 root 비밀번호를 설정하고, 관리용 일반 계정을 함께 생성하는 것을 권장한다.
예시:
사용자 이름: admin
관리자 권한: 활성화
설치 완료 후 시스템을 재부팅한다.
2. 설치 직후 기본 확인
2.1 운영체제 버전 확인
cat /etc/os-release
uname -r
hostnamectl
2.2 현재 사용자 확인
whoami
root 계정으로 전환:
sudo -i
2.3 패키지 업데이트
dnf update -y
커널이 업데이트되었으면 재부팅한다.
reboot
3. CLI에서 IP 주소 설정
Rocky Linux 9는 NetworkManager를 기본 네트워크 관리 서비스로 사용한다.
CLI에서는 주로 nmcli 명령어를 사용한다.
3.1 네트워크 인터페이스 확인
ip address
ip -br address
nmcli device status
3.2 네트워크 연결 프로파일 확인
nmcli connection show
장치 이름과 연결 프로파일 이름은 다를 수 있다.
3.3 DHCP 설정
연결 프로파일 이름이 ens192인 경우:
nmcli connection modify ens192 ipv4.method auto
nmcli connection modify ens192 ipv4.addresses ""
nmcli connection modify ens192 ipv4.gateway ""
nmcli connection modify ens192 ipv4.dns ""
nmcli connection up ens192
확인:
ip -br address show ens192
ip route
cat /etc/resolv.conf
3.4 고정 IP 설정
예시 환경:
| 항목 | 설정값 |
|---|---|
| 연결 프로파일 | ens192 |
| IP 주소 | 192.168.10.20 |
| 서브넷 | /24 |
| 기본 게이트웨이 | 192.168.10.1 |
| DNS 서버 | 192.168.10.1, 8.8.8.8 |
설정:
nmcli connection modify ens192 \
ipv4.method manual \
ipv4.addresses 192.168.10.20/24 \
ipv4.gateway 192.168.10.1 \
ipv4.dns "192.168.10.1 8.8.8.8"
nmcli connection modify ens192 connection.autoconnect yes
nmcli connection up ens192
원격 SSH 접속 상태에서 IP 주소를 변경하면 접속이 끊길 수 있다.
가능하면 콘솔, iLO, iDRAC, IPMI, VMware 콘솔 등 별도의 관리 경로를 확보한 후 변경한다.
3.5 설정 결과 확인
ip -br address
ip route
ping -c 4 192.168.10.1
ping -c 4 8.8.8.8
ping -c 4 google.com
8.8.8.8 통신은 되지만 도메인 이름 통신이 되지 않으면 DNS 설정을 확인한다.
3.6 네트워크 설정 상세 확인
nmcli connection show ens192
nmcli -f ipv4 connection show ens192
4. 네트워크 인터페이스 본딩 설정
네트워크 본딩은 두 개 이상의 물리 인터페이스를 하나의 논리 인터페이스로 묶어 장애 절체 또는 부하 분산을 구성하는 기능이다.
4.1 본딩 설정 전 주의사항
본딩 설정 중 네트워크가 중단될 수 있으므로 반드시 콘솔 접속 수단을 확보한다.
기존 설정 백업:
BACKUP_DIR="/root/network-backup-$(date +%Y%m%d_%H%M%S)"
mkdir -p "$BACKUP_DIR"
cp -a /etc/NetworkManager/system-connections "$BACKUP_DIR/" 2>/dev/null
cp -a /etc/sysconfig/network-scripts "$BACKUP_DIR/" 2>/dev/null
nmcli connection show > "$BACKUP_DIR/nmcli-connection.txt"
ip address > "$BACKUP_DIR/ip-address.txt"
ip route > "$BACKUP_DIR/ip-route.txt"
4.2 본딩 모드 종류
| 모드 | 이름 | 동작 방식 | 스위치 설정 | 권장 용도 |
|---|---|---|---|---|
| mode=0 | balance-rr | 패킷을 순차적으로 각 인터페이스에 전송 | 정적 포트 채널 필요 | 특수 부하 분산 |
| mode=1 | active-backup | 하나의 링크만 사용하고 장애 시 예비 링크로 전환 | 일반적으로 불필요 | 서버 이중화 |
| mode=2 | balance-xor | MAC 기반으로 송신 인터페이스 선택 | 정적 포트 채널 필요 | 고정 방식 부하 분산 |
| mode=3 | broadcast | 모든 링크로 동일 패킷 전송 | 환경에 따라 필요 | 특수 고가용성 |
| mode=4 | 802.3ad | LACP 기반 부하 분산 | LACP 포트 채널 필수 | 대역폭 확장 및 이중화 |
| mode=5 | balance-tlb | 송신 부하 분산 | 일반적으로 불필요 | 제한된 스위치 환경 |
| mode=6 | balance-alb | 송수신 부하 분산 | 일반적으로 불필요 | 제한된 스위치 환경 |
일반적인 서버에서는 active-backup 또는 802.3ad를 주로 사용한다.
4.3 구성 예시
| 항목 | 설정값 |
|---|---|
| 첫 번째 인터페이스 | ens192 |
| 두 번째 인터페이스 | ens224 |
| 본딩 인터페이스 | bond0 |
| 본딩 모드 | active-backup |
| IP 주소 | 192.168.10.20/24 |
| 기본 게이트웨이 | 192.168.10.1 |
| DNS 서버 | 192.168.10.1, 8.8.8.8 |
| 우선 인터페이스 | ens192 |
확인:
ip -br link
nmcli device status
nmcli connection show
4.4 active-backup 본딩 생성
nmcli connection add \
type bond \
con-name bond0 \
ifname bond0 \
bond.options "mode=active-backup,miimon=100,primary=ens192"
첫 번째 포트 추가:
nmcli connection add \
type ethernet \
con-name bond0-port1 \
ifname ens192 \
master bond0 \
slave-type bond
두 번째 포트 추가:
nmcli connection add \
type ethernet \
con-name bond0-port2 \
ifname ens224 \
master bond0 \
slave-type bond
4.5 bond0 고정 IP 설정
nmcli connection modify bond0 \
ipv4.method manual \
ipv4.addresses 192.168.10.20/24 \
ipv4.gateway 192.168.10.1 \
ipv4.dns "192.168.10.1 8.8.8.8" \
ipv6.method disabled \
connection.autoconnect yes
nmcli connection modify bond0-port1 connection.autoconnect yes
nmcli connection modify bond0-port2 connection.autoconnect yes
지원되는 경우:
nmcli connection modify bond0 connection.autoconnect-ports 1
구형 속성명만 지원하는 경우:
nmcli connection modify bond0 connection.autoconnect-slaves 1
4.6 본딩 활성화
nmcli connection up bond0-port1
nmcli connection up bond0-port2
nmcli connection up bond0
4.7 DHCP 본딩 설정
nmcli connection modify bond0 \
ipv4.method auto \
ipv4.addresses "" \
ipv4.gateway "" \
ipv4.dns ""
nmcli connection up bond0
4.8 802.3ad LACP 본딩 설정
스위치에서 LACP 포트 채널 구성이 먼저 완료되어 있어야 한다.
nmcli connection add \
type bond \
con-name bond0 \
ifname bond0 \
bond.options "mode=802.3ad,miimon=100,lacp_rate=fast,xmit_hash_policy=layer3+4"
포트 추가:
nmcli connection add \
type ethernet \
con-name bond0-port1 \
ifname ens192 \
master bond0 \
slave-type bond
nmcli connection add \
type ethernet \
con-name bond0-port2 \
ifname ens224 \
master bond0 \
slave-type bond
IP 설정:
nmcli connection modify bond0 \
ipv4.method manual \
ipv4.addresses 192.168.10.20/24 \
ipv4.gateway 192.168.10.1 \
ipv4.dns "192.168.10.1 8.8.8.8" \
connection.autoconnect yes
활성화:
nmcli connection up bond0-port1
nmcli connection up bond0-port2
nmcli connection up bond0
단일 TCP 세션 하나의 속도가 물리 링크 합산 속도로 증가하는 방식은 아니다.
4.9 본딩 상태 확인
nmcli device status
nmcli connection show
ip -br address show bond0
cat /proc/net/bonding/bond0
주요 확인 항목:
| 항목 | 확인 내용 |
|---|---|
| Bonding Mode | 설정한 본딩 모드 |
| Currently Active Slave | 현재 활성 인터페이스 |
| MII Status | 물리 링크 up/down 상태 |
| Slave Interface | 본딩 포함 인터페이스 |
| Link Failure Count | 링크 장애 횟수 |
| Aggregator ID | LACP 링크가 같은 Aggregator인지 확인 |
4.10 active-backup 절체 테스트
grep "Currently Active Slave" /proc/net/bonding/bond0
ping 192.168.10.1
다른 콘솔에서 활성 인터페이스를 내린다.
ip link set ens192 down
절체 확인:
grep "Currently Active Slave" /proc/net/bonding/bond0
복구:
ip link set ens192 up
nmcli device status
cat /proc/net/bonding/bond0
4.11 물리 링크 확인
ethtool ens192 | grep -E 'Speed|Duplex|Link detected'
ethtool ens224 | grep -E 'Speed|Duplex|Link detected'
5. 구형 ifcfg 파일 형식 적용
일부 구형 콜서버, PBX, CTI 또는 제조사 애플리케이션은 다음 경로의 설정 파일을 직접 확인하는 경우가 있다.
/etc/sysconfig/network-scripts/ifcfg-bond0
/etc/sysconfig/network-scripts/ifcfg-ens192
/etc/sysconfig/network-scripts/ifcfg-ens224
Rocky Linux 9에서는 ifcfg 파일을 사용하더라도 실제 네트워크 제어는 NetworkManager가 수행한다.
NetworkManager를 비활성화하고 구형 network 서비스를 활성화하는 방식은 사용하지 않는다.
5.1 현재 프로파일 저장 위치 확인
nmcli -f NAME,UUID,TYPE,DEVICE,FILENAME connection show
5.2 ifcfg-rh 플러그인 확인
NetworkManager --version
nmcli --version
find /usr/lib64/NetworkManager /usr/lib/NetworkManager \
-type f -iname '*ifcfg*' 2>/dev/null
rpm -qa | grep -E '^NetworkManager|ifcfg'
nmcli connection help | grep -A5 migrate
5.3 keyfile을 ifcfg 형식으로 변환
변환 전 백업:
BACKUP_DIR="/root/network-profile-backup-$(date +%Y%m%d_%H%M%S)"
mkdir -p "$BACKUP_DIR"
cp -a /etc/NetworkManager/system-connections "$BACKUP_DIR/"
cp -a /etc/sysconfig/network-scripts "$BACKUP_DIR/" 2>/dev/null
변환:
nmcli connection migrate --plugin ifcfg-rh id bond0
nmcli connection migrate --plugin ifcfg-rh id bond0-port1
nmcli connection migrate --plugin ifcfg-rh id bond0-port2
결과 확인:
nmcli -f NAME,TYPE,DEVICE,FILENAME connection show
ls -l /etc/sysconfig/network-scripts/ifcfg-*
5.4 실제 인터페이스명 파일이 필요한 경우
일부 프로그램은 다음 파일명을 요구할 수 있다.
ifcfg-ens192
ifcfg-ens224
프로파일 이름 변경:
nmcli connection modify bond0-port1 connection.id ens192
nmcli connection modify bond0-port2 connection.id ens224
다시 변환:
nmcli connection migrate --plugin ifcfg-rh id ens192
nmcli connection migrate --plugin ifcfg-rh id ens224
확인:
nmcli -f NAME,DEVICE,FILENAME connection show
ls -l /etc/sysconfig/network-scripts/ifcfg-*
5.5 ifcfg-bond0 예시
TYPE=Bond
BONDING_MASTER=yes
NAME=bond0
DEVICE=bond0
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.10.20
PREFIX=24
GATEWAY=192.168.10.1
DNS1=192.168.10.1
DNS2=8.8.8.8
BONDING_OPTS="mode=active-backup miimon=100 primary=ens192"
IPV6INIT=no
5.6 ifcfg-ens192 예시
TYPE=Ethernet
NAME=ens192
DEVICE=ens192
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
5.7 ifcfg-ens224 예시
TYPE=Ethernet
NAME=ens224
DEVICE=ens224
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
5.8 ifcfg 파일 직접 작성
기존 설정 백업:
cp -a /etc/sysconfig/network-scripts \
/root/network-scripts-backup-$(date +%Y%m%d_%H%M%S)
파일 작성 후 권한 설정:
chmod 600 /etc/sysconfig/network-scripts/ifcfg-bond0
chmod 600 /etc/sysconfig/network-scripts/ifcfg-ens192
chmod 600 /etc/sysconfig/network-scripts/ifcfg-ens224
nmcli connection reload
nmcli -f NAME,DEVICE,TYPE,FILENAME connection show
동일 장치의 keyfile과 ifcfg 파일이 함께 존재하면 중복 프로파일이 생성될 수 있다.
5.9 중복 프로파일 확인
nmcli -f NAME,UUID,DEVICE,TYPE,FILENAME connection show
사용하지 않는 프로파일 삭제:
nmcli connection delete 사용하지_않는_프로파일명
nmcli connection reload
5.10 keyfile 형식으로 복원
cp -a /etc/sysconfig/network-scripts \
/root/ifcfg-backup-$(date +%Y%m%d_%H%M%S)
nmcli connection migrate --plugin keyfile id bond0
nmcli connection migrate --plugin keyfile id ens192
nmcli connection migrate --plugin keyfile id ens224
nmcli -f NAME,DEVICE,TYPE,FILENAME connection show
nmcli connection reload
6. 호스트 이름 설정
6.1 현재 호스트 이름 확인
hostname
hostnamectl
6.2 호스트 이름 변경
hostnamectl set-hostname rocky-file01
FQDN 형식:
hostnamectl set-hostname rocky-file01.example.local
확인:
hostnamectl
hostname
6.3 /etc/hosts 등록
백업:
cp -a /etc/hosts /etc/hosts.bak.$(date +%Y%m%d_%H%M%S)
편집:
vi /etc/hosts
예시:
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
192.168.10.20 rocky-file01.example.local rocky-file01
확인:
getent hosts rocky-file01
7. SSH 기본 설정
7.1 SSH 서버 설치 확인
rpm -q openssh-server
미설치 시:
dnf install -y openssh-server
7.2 SSH 서비스 시작
systemctl enable --now sshd
systemctl status sshd
systemctl is-active sshd
systemctl is-enabled sshd
7.3 설정 파일 백업
cp -a /etc/ssh/sshd_config \
/etc/ssh/sshd_config.bak.$(date +%Y%m%d_%H%M%S)
추가 설정 파일 생성:
vi /etc/ssh/sshd_config.d/10-custom.conf
7.4 기본 보안 설정 예시
PermitRootLogin no
MaxAuthTries 5
LoginGraceTime 60
X11Forwarding no
문법 검사:
sshd -t
설정 적용:
systemctl reload sshd
기존 SSH 세션을 닫기 전에 새 터미널에서 접속 성공 여부를 확인한다.
8. SSH 접속 계정 제한
8.1 관리 계정 생성
useradd admin
passwd admin
usermod -aG wheel admin
id admin
8.2 특정 계정만 접속 허용
vi /etc/ssh/sshd_config.d/10-custom.conf
설정:
AllowUsers admin
여러 계정:
AllowUsers admin operator backupuser
그룹 기준:
AllowGroups wheel
문법 검사 및 적용:
sshd -t
systemctl reload sshd
9. SSH 포트 변경
예시로 SSH 포트를 2222번으로 변경한다.
9.1 SSH 설정 변경
vi /etc/ssh/sshd_config.d/10-custom.conf
Port 2222
문법 검사:
sshd -t
9.2 SELinux 포트 등록
dnf install -y policycoreutils-python-utils
semanage port -l | grep ssh
semanage port -a -t ssh_port_t -p tcp 2222
이미 등록된 포트라면:
semanage port -m -t ssh_port_t -p tcp 2222
9.3 firewalld 포트 허용
firewall-cmd --permanent --add-port=2222/tcp
firewall-cmd --reload
firewall-cmd --list-ports
9.4 SSH 재시작 및 확인
systemctl restart sshd
systemctl status sshd
ss -lntp | grep 2222
새 포트 접속 테스트:
ssh -p 2222 admin@192.168.10.20
정상 접속 후 기존 22번 허용 제거:
firewall-cmd --permanent --remove-service=ssh
firewall-cmd --reload
10. firewalld 기본 사용법
10.1 상태 확인
systemctl status firewalld
systemctl is-active firewalld
systemctl is-enabled firewalld
시작:
systemctl enable --now firewalld
10.2 존 및 설정 확인
firewall-cmd --get-active-zones
firewall-cmd --get-default-zone
firewall-cmd --list-all
10.3 서비스 허용
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload
10.4 포트 번호 허용
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --permanent --add-port=514/tcp
firewall-cmd --permanent --add-port=514/udp
firewall-cmd --reload
10.5 허용 설정 제거
firewall-cmd --permanent --remove-port=8080/tcp
firewall-cmd --permanent --remove-service=http
firewall-cmd --reload
10.6 특정 IP 대역만 SSH 허용
firewall-cmd --permanent \
--add-rich-rule='rule family="ipv4" source address="192.168.10.0/24" port port="22" protocol="tcp" accept'
firewall-cmd --permanent --remove-service=ssh
firewall-cmd --reload
firewall-cmd --list-rich-rules
11. firewalld 비활성화 및 iptables 전환
Rocky Linux 9에서는 firewalld 사용을 우선 권장한다.
기존 운영 환경이 iptables 규칙으로 표준화된 경우에만 전환을 고려한다.
11.1 기존 방화벽 규칙 백업
firewall-cmd --list-all-zones > /root/firewalld-backup-$(date +%Y%m%d_%H%M%S).txt
nft list ruleset > /root/nftables-backup-$(date +%Y%m%d_%H%M%S).txt
11.2 iptables 서비스 설치
dnf install -y iptables-services
rpm -q iptables-services
11.3 firewalld 비활성화
systemctl disable --now firewalld
systemctl is-active firewalld
systemctl is-enabled firewalld
11.4 iptables 기본 규칙 작성
vi /etc/sysconfig/iptables
예시:
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -p tcp --dport 22 -j ACCEPT
-A INPUT -p udp --dport 137 -j ACCEPT
-A INPUT -p udp --dport 138 -j ACCEPT
-A INPUT -p tcp --dport 139 -j ACCEPT
-A INPUT -p tcp --dport 445 -j ACCEPT
-A INPUT -m conntrack --ctstate INVALID -j DROP
COMMIT
SSH 포트를 2222번으로 변경했다면 다음과 같이 수정한다.
-A INPUT -p tcp --dport 2222 -j ACCEPT
11.5 iptables 서비스 시작
systemctl enable --now iptables
systemctl status iptables
iptables -L -n -v --line-numbers
service iptables save
또는:
iptables-save > /etc/sysconfig/iptables12. 서비스 정상 유무 확인
12.1 systemctl 확인
systemctl status sshd
systemctl status smb
systemctl status nmb
systemctl is-active sshd
systemctl is-active smb
systemctl is-enabled sshd
systemctl is-enabled smb12.2 실패한 서비스 확인
systemctl --failed
journalctl -u sshd -n 50 --no-pager
journalctl -u smb -n 50 --no-pager12.3 설정 문법 검사
sshd -t
testparm13. 서비스 포트 리스닝 확인
ss -lntup
ss -lntp
ss -lnup
ss -lntp | grep ':22'
ss -lntp | grep ':2222'
ss -lntup | grep -E ':137|:138|:139|:445'확인 항목:
| 항목 | 설명 |
|---|---|
| LISTEN | 연결 대기 상태 |
| 0.0.0.0:22 | 모든 IPv4 인터페이스에서 수신 |
| [::]:22 | 모든 IPv6 인터페이스에서 수신 |
| 127.0.0.1 | 로컬 서버에서만 접근 가능 |
| users | 해당 포트를 사용하는 프로세스 |
14. 외부에서 포트 오픈 여부 확인
14.1 Linux에서 nc 사용
dnf install -y nmap-ncat
nc -zv 192.168.10.20 22
nc -zv 192.168.10.20 2222
nc -zv 192.168.10.20 44514.2 Windows PowerShell에서 확인
Test-NetConnection 192.168.10.20 -Port 22
Test-NetConnection 192.168.10.20 -Port 2222
Test-NetConnection 192.168.10.20 -Port 44515. SSH 접속 테스트
기본 포트:
ssh admin@192.168.10.20변경 포트:
ssh -p 2222 admin@192.168.10.20SSH 장애 확인 순서:
- 서버 IP 통신 확인
- SSH 서비스 상태 확인
- SSH 설정 문법 확인
- SSH 포트 리스닝 확인
- 방화벽 규칙 확인
- SELinux 포트 등록 확인
- SSH 로그 확인
ping -c 4 192.168.10.20
systemctl status sshd
sshd -t
ss -lntp | grep sshd
firewall-cmd --list-all
semanage port -l | grep ssh
journalctl -u sshd -n 100 --no-pager16. SFTP 접속 테스트
SFTP는 SSH 서비스를 사용하며 별도 FTP 서버가 필요하지 않다.
기본 포트:
sftp admin@192.168.10.20변경 포트:
sftp -P 2222 admin@192.168.10.20주요 명령:
| 명령어 | 설명 |
|---|---|
| pwd | 서버 현재 디렉터리 |
| lpwd | 로컬 현재 디렉터리 |
| ls | 서버 파일 목록 |
| lls | 로컬 파일 목록 |
| get 파일명 | 파일 다운로드 |
| put 파일명 | 파일 업로드 |
| exit | 종료 |
FileZilla 설정:
| 항목 | 설정값 |
|---|---|
| 프로토콜 | SFTP - SSH File Transfer Protocol |
| 호스트 | 192.168.10.20 |
| 포트 | 22 또는 변경한 SSH 포트 |
| 사용자 | admin |
| 비밀번호 | 해당 계정 비밀번호 |
17. Samba 파일 공유 설정
17.1 Samba 설치
dnf install -y samba samba-client
rpm -q samba
rpm -q samba-client17.2 공유 계정 생성
useradd -m shareuser
passwd shareuser
smbpasswd -a shareuser
smbpasswd -e shareuser
pdbedit -L17.3 공유 디렉터리 생성
mkdir -p /data/share
chown -R shareuser:shareuser /data/share
chmod 2770 /data/share
ls -ld /data/share17.4 Samba 설정 백업
cp -a /etc/samba/smb.conf \
/etc/samba/smb.conf.bak.$(date +%Y%m%d_%H%M%S)17.5 Samba 설정
vi /etc/samba/smb.conf[global]
workgroup = WORKGROUP
security = user
map to guest = never
server min protocol = SMB2
server role = standalone server
[share]
comment = Shared Folder
path = /data/share
browseable = yes
writable = yes
read only = no
valid users = shareuser
create mask = 0660
directory mask = 0770문법 검사:
testparm17.6 SELinux 설정
dnf install -y policycoreutils-python-utils
semanage fcontext -a -t samba_share_t "/data/share(/.*)?"
restorecon -Rv /data/share
ls -ldZ /data/share17.7 Samba 서비스 시작
systemctl enable --now smb
systemctl enable --now nmb
systemctl status smb
systemctl status nmb최신 Windows 환경에서 IP 주소 또는 DNS 이름으로 직접 접근하는 경우 smb 서비스만으로도 동작할 수 있다.
17.8 방화벽 허용
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload
firewall-cmd --list-services17.9 Samba 포트 확인
ss -lntup | grep -E ':137|:138|:139|:445'| 포트 | 프로토콜 | 용도 |
|---|---|---|
| 137 | UDP | NetBIOS 이름 서비스 |
| 138 | UDP | NetBIOS 데이터그램 |
| 139 | TCP | NetBIOS 세션 서비스 |
| 445 | TCP | SMB 직접 통신 |
17.10 서버 내부 테스트
smbclient -L localhost -U shareuser
smbclient //localhost/share -U shareuser17.11 Windows에서 접속
\\192.168.10.20\share호스트 이름으로 접근:
\\rocky-file01\shareWindows 자격 증명 초기화:
net use * /delete /y네트워크 드라이브 연결:
net use Z: \\192.168.10.20\share /user:shareuser17.12 Samba 장애 확인 순서
- 서버 IP 통신 확인
- smb 서비스 상태 확인
- TCP 445 포트 리스닝 확인
- 방화벽 허용 확인
- Samba 설정 문법 확인
- Samba 계정 확인
- Linux 디렉터리 권한 확인
- SELinux 컨텍스트 확인
- Samba 로그 확인
ping -c 4 192.168.10.20
systemctl status smb
ss -lntp | grep ':445'
firewall-cmd --list-all
testparm
pdbedit -L
ls -ld /data/share
ls -ldZ /data/share
journalctl -u smb -n 100 --no-pager
ausearch -m AVC -ts recent18. 전체 설정 최종 점검
18.1 시스템 정보
cat /etc/os-release
hostnamectl
timedatectl18.2 네트워크
ip -br address
ip route
nmcli device status
nmcli connection show
ping -c 4 192.168.10.1본딩 사용 시:
cat /proc/net/bonding/bond0
nmcli -f NAME,UUID,DEVICE,TYPE,FILENAME connection show18.3 SSH
systemctl is-active sshd
systemctl is-enabled sshd
sshd -t
ss -lntp | grep sshd
journalctl -u sshd -n 30 --no-pager18.4 방화벽
firewalld 사용 시:
systemctl is-active firewalld
firewall-cmd --get-active-zones
firewall-cmd --list-alliptables 사용 시:
systemctl is-active iptables
iptables -L -n -v --line-numbers
iptables-save18.5 Samba
systemctl is-active smb
systemctl is-enabled smb
testparm
pdbedit -L
ss -lntup | grep -E ':137|:138|:139|:445'
ls -ldZ /data/share19. 구축 완료 후 권장 사항
19.1 root 원격 로그인 차단
PermitRootLogin no19.2 관리자 계정 사용
usermod -aG wheel admin19.3 불필요한 서비스 비활성화
systemctl --type=service --state=running
systemctl disable --now 서비스명19.4 정기 업데이트
dnf check-update
dnf update -y19.5 시간 동기화 확인
timedatectl
chronyc tracking
chronyc sources -v서울 시간대 설정:
timedatectl set-timezone Asia/Seoul19.6 주요 설정 백업
tar czvf /root/rocky-basic-config-$(date +%Y%m%d).tar.gz \
/etc/NetworkManager/system-connections \
/etc/sysconfig/network-scripts \
/etc/hosts \
/etc/hostname \
/etc/ssh \
/etc/firewalld \
/etc/sysconfig/iptables \
/etc/samba/smb.conf 2>/dev/null20. 전체 작업 순서 요약
1. Rocky Linux 9 설치
2. 설치 후 패키지 업데이트
3. 네트워크 인터페이스 확인
4. 단일 NIC 또는 본딩 구성
5. 고정 IP 및 DNS 설정
6. 필요 시 ifcfg 형식으로 변환
7. 게이트웨이와 외부 통신 확인
8. 호스트 이름 설정
9. 관리자 계정 생성
10. SSH 서비스 확인
11. root 직접 로그인 차단
12. 필요 시 SSH 허용 계정 제한
13. 필요 시 SSH 포트 변경
14. SELinux에 변경 포트 등록
15. 방화벽 포트 허용
16. SSH와 SFTP 접속 테스트
17. Samba 패키지 설치
18. Samba 계정 및 공유 디렉터리 생성
19. Samba 설정 파일 작성
20. SELinux 컨텍스트 설정
21. Samba 방화벽 허용
22. Windows에서 공유 접속 테스트
23. 전체 설정 파일 백업21. 빠른 점검 명령어 모음
# OS 버전
cat /etc/os-release
# 호스트 이름
hostnamectl
# IP 주소
ip -br address
# 라우팅
ip route
# NetworkManager
nmcli device status
nmcli connection show
# 본딩
cat /proc/net/bonding/bond0
# SSH 상태
systemctl status sshd
# SSH 문법
sshd -t
# 포트 리스닝
ss -lntup
# firewalld
firewall-cmd --list-all
# iptables
iptables -L -n -v --line-numbers
# Samba 문법
testparm
# Samba 계정
pdbedit -L
# Samba 서비스
systemctl status smb
# 실패한 서비스
systemctl --failed
# 최근 부팅 오류
journalctl -p err -b --no-pager관련 문서
- Rocky Linux 9 사용자 및 그룹 관리
- Rocky Linux 9 패키지 관리
- Rocky Linux 9 systemd 서비스 관리
- Rocky Linux 9 firewalld 상세 설정
- Rocky Linux 9 SSH 키 인증 설정
- Rocky Linux 9 SELinux 기본 관리
- Rocky Linux 9 Samba 고급 설정
- Rocky Linux 9 로그 확인 및 장애 분석