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 계정으로 실행하는 것을 기준으로 한다.


일반 계정으로 실행할 경우 명령어 앞에 <code>sudo</code>를 추가한다.
일반 계정으로 실행할 경우 명령어 앞에 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 설정 ===
서버 또는 PC 전원을 켠 후 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 설치 장치를 첫 번째로 설정 |
|}
| }                   |
 
VMware, KVM, Proxmox 등의 가상화 환경에 Rocky Linux를 설치하는 경우 ISO 파일을 가상 CD/DVD 장치에 연결한다.


=== 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 사용량이 크게 증가할 수 있으므로
| --------------- |
별도 볼륨으로 분리하는 것이 좋다.
| /boot/efi      |
| UEFI 부트 영역      |
| 600 MiB        |
| -              |
| /boot          |
| 커널 및 부트로더      |
| 1 GiB          |
| -              |
| /              |
| 운영체제 루트 영역      |
| 40 GiB 이상      |
| -              |
| /var            |
| 로그 및 서비스 데이터    |
| 사용 목적에 따라 결정    |
| -              |
| /home          |
| 사용자 홈 디렉터리      |
| 사용 목적에 따라 결정    |
| -              |
| swap            |
| 메모리 보조 공간      |
| 메모리 및 용도에 따라 결정 |
| }              |
 
로그 서버, DB 서버, 웹 서버는 <code>/var</code> 사용량이 크게 증가할 수 있으므로 별도 볼륨으로 분리하는 것이 좋다.


=== 1.6 소프트웨어 선택 ===
=== 1.6 소프트웨어 선택 ===
159번째 줄: 145번째 줄:
Server with GUI
Server with GUI
</syntaxhighlight>
</syntaxhighlight>
일반적인 서버는 보안과 자원 사용량을 고려하여 Minimal Install을 권장한다.


=== 1.7 root 비밀번호 및 사용자 생성 ===
=== 1.7 root 비밀번호 및 사용자 생성 ===


설치 과정에서 root 비밀번호를 설정한다.
설치 과정에서 root 비밀번호를 설정하고,
관리용 일반 계정을 함께 생성하는 것을 권장한다.


관리용 일반 계정도 함께 생성하는 것을 권장한다.
예시:
 
예시 계정:


<syntaxhighlight lang="text">
<syntaxhighlight lang="text">
174번째 줄: 157번째 줄:
관리자 권한: 활성화
관리자 권한: 활성화
</syntaxhighlight>
</syntaxhighlight>
관리자 권한을 활성화하면 해당 계정이 일반적으로 <code>wheel</code> 그룹에 추가된다.


설치 완료 후 시스템을 재부팅한다.
설치 완료 후 시스템을 재부팅한다.
185번째 줄: 166번째 줄:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cat /etc/os-release
cat /etc/os-release
</syntaxhighlight>
출력 예시:
<syntaxhighlight lang="text">
NAME="Rocky Linux"
VERSION="9.x"
ID="rocky"
</syntaxhighlight>
커널 버전 확인:
<syntaxhighlight lang="bash">
uname -r
uname -r
</syntaxhighlight>
전체 시스템 정보 확인:
<syntaxhighlight lang="bash">
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 lang="bash">
uname -r
</syntaxhighlight>
</syntaxhighlight>


243번째 줄: 198번째 줄:
Rocky Linux 9는 NetworkManager를 기본 네트워크 관리 서비스로 사용한다.
Rocky Linux 9는 NetworkManager를 기본 네트워크 관리 서비스로 사용한다.


CLI에서는 주로 <code>nmcli</code> 명령어를 사용한다.
CLI에서는 주로 nmcli 명령어를 사용한다.


=== 3.1 네트워크 인터페이스 확인 ===
=== 3.1 네트워크 인터페이스 확인 ===
249번째 줄: 204번째 줄:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ip address
ip address
</syntaxhighlight>
간단하게 확인:
<syntaxhighlight lang="bash">
ip -br address
ip -br address
</syntaxhighlight>
NetworkManager 장치 상태 확인:
<syntaxhighlight lang="bash">
nmcli device status
nmcli device status
</syntaxhighlight>
</syntaxhighlight>
출력 예시:
<syntaxhighlight lang="text">
DEVICE  TYPE      STATE      CONNECTION
ens192  ethernet  connected  ens192
lo      loopback  connected  lo
</syntaxhighlight>
위 예시에서 물리 네트워크 인터페이스는 <code>ens192</code>이다.


=== 3.2 네트워크 연결 프로파일 확인 ===
=== 3.2 네트워크 연결 프로파일 확인 ===
277번째 줄: 212번째 줄:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
nmcli connection show
nmcli connection show
</syntaxhighlight>
출력 예시:
<syntaxhighlight lang="text">
NAME    UUID                                  TYPE      DEVICE
ens192  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  ethernet  ens192
</syntaxhighlight>
</syntaxhighlight>


장치 이름과 연결 프로파일 이름은 다를 수 있다.
장치 이름과 연결 프로파일 이름은 다를 수 있다.
이후 명령어에서는 연결 프로파일 이름을 정확히 사용해야 한다.


=== 3.3 DHCP 설정 ===
=== 3.3 DHCP 설정 ===


연결 프로파일 이름이 <code>ens192</code>인 경우:
연결 프로파일 이름이 ens192인 경우:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
302번째 줄: 228번째 줄:
</syntaxhighlight>
</syntaxhighlight>


현재 할당된 IP 주소 확인:
확인:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ip -br address show ens192
ip -br address show ens192
</syntaxhighlight>
기본 게이트웨이 확인:
<syntaxhighlight lang="bash">
ip route
ip route
</syntaxhighlight>
DNS 확인:
<syntaxhighlight lang="bash">
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
|}


| ! 설정값                |
설정:
| --------------------- |
| 연결 프로파일              |
| ens192                |
| -                    |
| IP 주소                |
| 192.168.10.20        |
| -                    |
| 서브넷                  |
| /24                  |
| -                    |
| 기본 게이트웨이              |
| 192.168.10.1          |
| -                    |
| DNS 서버                |
| 192.168.10.1, 8.8.8.8 |
| }                    |
 
고정 IP 설정:


<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"
</syntaxhighlight>
자동 연결 활성화:


<syntaxhighlight lang="bash">
nmcli connection modify ens192 connection.autoconnect yes
nmcli connection modify ens192 connection.autoconnect yes
</syntaxhighlight>
설정 적용:
<syntaxhighlight lang="bash">
nmcli connection up ens192
nmcli connection up ens192
</syntaxhighlight>
</syntaxhighlight>
372번째 줄: 279번째 줄:


=== 3.5 설정 결과 확인 ===
=== 3.5 설정 결과 확인 ===
IP 주소 확인:


<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">
ip route
nmcli connection show ens192
nmcli -f ipv4 connection show ens192
</syntaxhighlight>
</syntaxhighlight>


게이트웨이 통신 확인:
== 4. 네트워크 인터페이스 본딩 설정 ==
 
네트워크 본딩은 두 개 이상의 물리 인터페이스를 하나의 논리 인터페이스로 묶어
장애 절체 또는 부하 분산을 구성하는 기능이다.
 
=== 4.1 본딩 설정 전 주의사항 ===
 
본딩 설정 중 네트워크가 중단될 수 있으므로 반드시 콘솔 접속 수단을 확보한다.
 
기존 설정 백업:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ping -c 4 192.168.10.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"
</syntaxhighlight>
</syntaxhighlight>


외부 IP 통신 확인:
=== 4.2 본딩 모드 종류 ===


<syntaxhighlight lang="bash">
{| class="wikitable"
ping -c 4 8.8.8.8
|-
</syntaxhighlight>
! 모드
! 이름
! 동작 방식
! 스위치 설정
! 권장 용도
|-
| 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
| 송수신 부하 분산
| 일반적으로 불필요
| 제한된 스위치 환경
|}


DNS 이름 조회 확인:
일반적인 서버에서는 active-backup 또는 802.3ad를 주로 사용한다.


<syntaxhighlight lang="bash">
=== 4.3 구성 예시 ===
ping -c 4 google.com
</syntaxhighlight>


<code>8.8.8.8</code> 통신은 되지만 도메인 이름 통신이 되지 않으면 DNS 설정을 확인한다.
{| 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
|}


=== 3.6 네트워크 설정 상세 확인 ===
확인:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
nmcli connection show ens192
ip -br link
nmcli device status
nmcli connection show
</syntaxhighlight>
</syntaxhighlight>


IPv4 관련 항목만 확인:
=== 4.4 active-backup 본딩 생성 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
nmcli -f ipv4 connection show ens192
nmcli connection add \
type bond \
con-name bond0 \
ifname bond0 \
bond.options "mode=active-backup,miimon=100,primary=ens192"
</syntaxhighlight>
</syntaxhighlight>


== 4. 호스트 이름 설정 ==
첫 번째 포트 추가:
 
=== 4.1 현재 호스트 이름 확인 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
hostname
nmcli connection add \
type ethernet \
con-name bond0-port1 \
ifname ens192 \
master bond0 \
slave-type bond
</syntaxhighlight>
</syntaxhighlight>


상세 확인:
두 번째 포트 추가:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
hostnamectl
nmcli connection add \
type ethernet \
con-name bond0-port2 \
ifname ens224 \
master bond0 \
slave-type bond
</syntaxhighlight>
</syntaxhighlight>


=== 4.2 호스트 이름 변경 ===
=== 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


<syntaxhighlight lang="text">
nmcli connection modify bond0-port1 connection.autoconnect yes
rocky-file01
nmcli connection modify bond0-port2 connection.autoconnect yes
</syntaxhighlight>
</syntaxhighlight>


설정 명령어:
지원되는 경우:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
hostnamectl set-hostname rocky-file01
nmcli connection modify bond0 connection.autoconnect-ports 1
</syntaxhighlight>
</syntaxhighlight>


FQDN 형식으로 설정할 수도 있다.
구형 속성명만 지원하는 경우:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
hostnamectl set-hostname rocky-file01.example.local
nmcli connection modify bond0 connection.autoconnect-slaves 1
</syntaxhighlight>
</syntaxhighlight>


설정 확인:
=== 4.6 본딩 활성화 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
hostnamectl
nmcli connection up bond0-port1
hostname
nmcli connection up bond0-port2
nmcli connection up bond0
</syntaxhighlight>
</syntaxhighlight>


=== 4.3 /etc/hosts 등록 ===
=== 4.7 DHCP 본딩 설정 ===


내부 DNS가 없는 환경에서는 <code>/etc/hosts</code>에 서버 정보를 등록할 수 있다.
<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">
cp -a /etc/hosts /etc/hosts.bak.$(date +%Y%m%d_%H%M%S)
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">
vi /etc/hosts
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="text">
<syntaxhighlight lang="bash">
127.0.0.1      localhost localhost.localdomain
nmcli connection modify bond0 \
::1             localhost localhost.localdomain
ipv4.method manual \
192.168.10.20  rocky-file01.example.local rocky-file01
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">
getent hosts rocky-file01
nmcli connection up bond0-port1
nmcli connection up bond0-port2
nmcli connection up bond0
</syntaxhighlight>
</syntaxhighlight>


== 5. SSH 기본 설정 ==
단일 TCP 세션 하나의 속도가 물리 링크 합산 속도로 증가하는 방식은 아니다.
 
=== 4.9 본딩 상태 확인 ===


SSH는 원격에서 서버 CLI에 접속하기 위한 서비스다.
<syntaxhighlight lang="bash">
nmcli device status
nmcli connection show
ip -br address show bond0
cat /proc/net/bonding/bond0
</syntaxhighlight>


SFTP도 SSH 서비스를 이용하므로 SSH 설정과 동일한 포트를 사용한다.
주요 확인 항목:


=== 5.1 SSH 서버 설치 여부 확인 ===
{| 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">
rpm -q openssh-server
grep "Currently Active Slave" /proc/net/bonding/bond0
ping 192.168.10.1
</syntaxhighlight>
</syntaxhighlight>


설치되지 않은 경우:
다른 콘솔에서 활성 인터페이스를 내린다.


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
dnf install -y openssh-server
ip link set ens192 down
</syntaxhighlight>
</syntaxhighlight>


=== 5.2 SSH 서비스 시작 및 자동 시작 설정 ===
절체 확인:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl enable --now sshd
grep "Currently Active Slave" /proc/net/bonding/bond0
</syntaxhighlight>
</syntaxhighlight>


서비스 상태 확인:
복구:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl status sshd
ip link set ens192 up
nmcli device status
cat /proc/net/bonding/bond0
</syntaxhighlight>
</syntaxhighlight>


간단하게 정상 여부만 확인:
=== 4.11 물리 링크 확인 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl is-active sshd
ethtool ens192 | grep -E 'Speed|Duplex|Link detected'
systemctl is-enabled sshd
ethtool ens224 | grep -E 'Speed|Duplex|Link detected'
</syntaxhighlight>
</syntaxhighlight>


정상 상태 예시:
== 5. 구형 ifcfg 파일 형식 적용 ==
 
일부 구형 콜서버, PBX, CTI 또는 제조사 애플리케이션은
다음 경로의 설정 파일을 직접 확인하는 경우가 있다.


<syntaxhighlight lang="text">
<syntaxhighlight lang="text">
active
/etc/sysconfig/network-scripts/ifcfg-bond0
enabled
/etc/sysconfig/network-scripts/ifcfg-ens192
/etc/sysconfig/network-scripts/ifcfg-ens224
</syntaxhighlight>
</syntaxhighlight>


=== 5.3 SSH 기본 설정 파일 ===
Rocky Linux 9에서는 ifcfg 파일을 사용하더라도 실제 네트워크 제어는 NetworkManager가 수행한다.
 
NetworkManager를 비활성화하고 구형 network 서비스를 활성화하는 방식은 사용하지 않는다.


SSH 서버 설정 파일:
=== 5.1 현재 프로파일 저장 위치 확인 ===


<syntaxhighlight lang="text">
<syntaxhighlight lang="bash">
/etc/ssh/sshd_config
nmcli -f NAME,UUID,TYPE,DEVICE,FILENAME connection show
</syntaxhighlight>
</syntaxhighlight>


추가 설정 파일 디렉터리:
=== 5.2 ifcfg-rh 플러그인 확인 ===


<syntaxhighlight lang="text">
<syntaxhighlight lang="bash">
/etc/ssh/sshd_config.d/
NetworkManager --version
</syntaxhighlight>
nmcli --version


Rocky Linux 9에서는 기존 설정 파일 전체를 직접 수정하기보다 별도 설정 파일을 생성하는 방법도 사용할 수 있다.
find /usr/lib64/NetworkManager /usr/lib/NetworkManager \
-type f -iname '*ifcfg*' 2>/dev/null


예시:
rpm -qa | grep -E '^NetworkManager|ifcfg'


<syntaxhighlight lang="text">
nmcli connection help | grep -A5 migrate
/etc/ssh/sshd_config.d/10-custom.conf
</syntaxhighlight>
</syntaxhighlight>


=== 5.4 SSH 설정 백업 ===
=== 5.3 keyfile을 ifcfg 형식으로 변환 ===


설정 변경 반드시 백업한다.
변환 백업:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cp -a /etc/ssh/sshd_config \
BACKUP_DIR="/root/network-profile-backup-$(date +%Y%m%d_%H%M%S)"
/etc/ssh/sshd_config.bak.$(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">
vi /etc/ssh/sshd_config.d/10-custom.conf
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>


=== 5.5 기본 보안 설정 예시 ===
결과 확인:


<syntaxhighlight lang="apache">
<syntaxhighlight lang="bash">
PermitRootLogin no
nmcli -f NAME,TYPE,DEVICE,FILENAME connection show
MaxAuthTries 5
ls -l /etc/sysconfig/network-scripts/ifcfg-*
LoginGraceTime 60
X11Forwarding no
</syntaxhighlight>
</syntaxhighlight>


각 항목의 의미는 다음과 같다.
=== 5.4 실제 인터페이스명 파일이 필요한 경우 ===


{| class="wikitable"
일부 프로그램은 다음 파일명을 요구할 수 있다.
! 항목


| ! 설명                          |
<syntaxhighlight lang="text">
| ------------------------------ |
ifcfg-ens192
| PermitRootLogin no            |
ifcfg-ens224
| root 계정의 직접 SSH 로그인을 차단한다.    |
</syntaxhighlight>
| -                              |
| MaxAuthTries 5                |
| 한 연결에서 허용할 인증 실패 횟수를 제한한다.    |
| -                              |
| LoginGraceTime 60              |
| 인증을 완료해야 하는 제한 시간을 초 단위로 지정한다. |
| -                             |
| X11Forwarding no              |
| 사용하지 않는 X11 포워딩 기능을 비활성화한다.    |
| }                              |


설정 문법 검사:
프로파일 이름 변경:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sshd -t
nmcli connection modify bond0-port1 connection.id ens192
nmcli connection modify bond0-port2 connection.id ens224
</syntaxhighlight>
</syntaxhighlight>


아무 메시지도 출력되지 않으면 일반적으로 문법 오류가 없는 상태다.
다시 변환:
 
설정 적용:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl reload sshd
nmcli connection migrate --plugin ifcfg-rh id ens192
nmcli connection migrate --plugin ifcfg-rh id ens224
</syntaxhighlight>
</syntaxhighlight>


reload 실패 시:
확인:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl restart sshd
nmcli -f NAME,DEVICE,FILENAME connection show
ls -l /etc/sysconfig/network-scripts/ifcfg-*
</syntaxhighlight>
</syntaxhighlight>


SSH 설정을 변경한 후 기존 접속 세션을 즉시 종료하지 않는다.
=== 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. SSH 접속 계정 제한 ==
=== 5.6 ifcfg-ens192 예시 ===


=== 6.1 관리 계정 생성 ===
<syntaxhighlight lang="ini">
TYPE=Ethernet
NAME=ens192
DEVICE=ens192
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
</syntaxhighlight>


예시 계정:
=== 5.7 ifcfg-ens224 예시 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="ini">
useradd admin
TYPE=Ethernet
passwd admin
NAME=ens224
DEVICE=ens224
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
</syntaxhighlight>
</syntaxhighlight>


관리자 권한이 필요한 경우 <code>wheel</code> 그룹에 추가한다.
=== 5.8 ifcfg 파일 직접 작성 ===
 
기존 설정 백업:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
usermod -aG wheel admin
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">
id admin
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>


출력에 <code>wheel</code> 그룹이 포함되어 있는지 확인한다.
동일 장치의 keyfile과 ifcfg 파일이 함께 존재하면 중복 프로파일이 생성될 수 있다.
 
=== 6.2 특정 계정만 SSH 접속 허용 ===


설정 파일 편집:
=== 5.9 중복 프로파일 확인 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
vi /etc/ssh/sshd_config.d/10-custom.conf
nmcli -f NAME,UUID,DEVICE,TYPE,FILENAME connection show
</syntaxhighlight>
</syntaxhighlight>


특정 계정만 허용:
사용하지 않는 프로파일 삭제:


<syntaxhighlight lang="apache">
<syntaxhighlight lang="bash">
AllowUsers admin
nmcli connection delete 사용하지_않는_프로파일명
nmcli connection reload
</syntaxhighlight>
</syntaxhighlight>


여러 계정 허용:
=== 5.10 keyfile 형식으로 복원 ===


<syntaxhighlight lang="apache">
<syntaxhighlight lang="bash">
AllowUsers admin operator backupuser
cp -a /etc/sysconfig/network-scripts \
</syntaxhighlight>
/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


<syntaxhighlight lang="apache">
nmcli -f NAME,DEVICE,TYPE,FILENAME connection show
AllowGroups wheel
nmcli connection reload
</syntaxhighlight>
</syntaxhighlight>


<code>AllowUsers</code> 또는 <code>AllowGroups</code> 설정을 잘못 적용하면 SSH 접속이 모두 차단될 수 있다.
== 6. 호스트 이름 설정 ==


현재 사용 중인 관리 계정이 허용 목록에 포함되어 있는지 반드시 확인한다.
=== 6.1 현재 호스트 이름 확인 ===
 
문법 검사:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sshd -t
hostname
hostnamectl
</syntaxhighlight>
</syntaxhighlight>


설정 적용:
=== 6.2 호스트 이름 변경 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl reload sshd
hostnamectl set-hostname rocky-file01
</syntaxhighlight>
</syntaxhighlight>


== 7. SSH 포트 변경 ==
FQDN 형식:


SSH 기본 포트는 TCP 22번이다.
<syntaxhighlight lang="bash">
hostnamectl set-hostname rocky-file01.example.local
</syntaxhighlight>


외부에 직접 노출되는 서버는 자동화된 스캔 로그를 줄이기 위해 포트를 변경하는 경우가 있다.
확인:
 
포트 변경 자체는 강력한 보안 대책이 아니며, 계정 제한, 키 인증, 방화벽 접근 제어를 함께 적용해야 한다.
 
다음 예시에서는 SSH 포트를 TCP 2222번으로 변경한다.
 
=== 7.1 SSH 설정 변경 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
vi /etc/ssh/sshd_config.d/10-custom.conf
hostnamectl
hostname
</syntaxhighlight>
</syntaxhighlight>


설정 추가:
=== 6.3 /etc/hosts 등록 ===
 
<syntaxhighlight lang="apache">
Port 2222
</syntaxhighlight>


문법 검사:
백업:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sshd -t
cp -a /etc/hosts /etc/hosts.bak.$(date +%Y%m%d_%H%M%S)
</syntaxhighlight>
</syntaxhighlight>


아직 SSH 서비스를 재시작하지 않는다.
편집:
 
먼저 방화벽과 SELinux 설정을 적용해야 한다.
 
=== 7.2 SELinux에 SSH 포트 등록 ===
 
SELinux 관리 도구 설치:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
dnf install -y policycoreutils-python-utils
vi /etc/hosts
</syntaxhighlight>
</syntaxhighlight>


현재 SSH 포트 정책 확인:
예시:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="text">
semanage port -l | grep ssh
127.0.0.1      localhost localhost.localdomain
::1            localhost localhost.localdomain
192.168.10.20  rocky-file01.example.local rocky-file01
</syntaxhighlight>
</syntaxhighlight>


TCP 2222번을 SSH 포트로 등록:
확인:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
semanage port -a -t ssh_port_t -p tcp 2222
getent hosts rocky-file01
</syntaxhighlight>
</syntaxhighlight>


이미 포트가 등록되어 있다는 오류가 발생하면 수정 명령어를 사용한다.
== 7. SSH 기본 설정 ==
 
=== 7.1 SSH 서버 설치 확인 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
semanage port -m -t ssh_port_t -p tcp 2222
rpm -q openssh-server
</syntaxhighlight>
</syntaxhighlight>


등록 결과 확인:
미설치 시:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
semanage port -l | grep ssh
dnf install -y openssh-server
</syntaxhighlight>
</syntaxhighlight>


=== 7.3 firewalld에서 SSH 포트 허용 ===
=== 7.2 SSH 서비스 시작 ===
 
현재 활성 존 확인:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --get-active-zones
systemctl enable --now sshd
systemctl status sshd
systemctl is-active sshd
systemctl is-enabled sshd
</syntaxhighlight>
</syntaxhighlight>


기본 존에 TCP 2222번 허용:
=== 7.3 설정 파일 백업 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --permanent --add-port=2222/tcp
cp -a /etc/ssh/sshd_config \
firewall-cmd --reload
/etc/ssh/sshd_config.bak.$(date +%Y%m%d_%H%M%S)
</syntaxhighlight>
</syntaxhighlight>


확인:
추가 설정 파일 생성:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --list-ports
vi /etc/ssh/sshd_config.d/10-custom.conf
</syntaxhighlight>
</syntaxhighlight>


=== 7.4 SSH 서비스 재시작 ===
=== 7.4 기본 보안 설정 예시 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="apache">
systemctl restart sshd
PermitRootLogin no
MaxAuthTries 5
LoginGraceTime 60
X11Forwarding no
</syntaxhighlight>
</syntaxhighlight>


상태 확인:
문법 검사:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl status sshd
sshd -t
</syntaxhighlight>
</syntaxhighlight>


포트 리스닝 확인:
설정 적용:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ss -lntp | grep 2222
systemctl reload sshd
</syntaxhighlight>
</syntaxhighlight>


=== 7.5 새 포트 접속 테스트 ===
기존 SSH 세션을 닫기 전에 새 터미널에서 접속 성공 여부를 확인한다.
 
== 8. SSH 접속 계정 제한 ==


다른 PC 또는 새 터미널에서 테스트한다.
=== 8.1 관리 계정 생성 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ssh -p 2222 admin@192.168.10.20
useradd admin
passwd admin
usermod -aG wheel admin
id admin
</syntaxhighlight>
</syntaxhighlight>


접속이 정상임을 확인한 후 기존 22번 포트를 방화벽에서 제거한다.
=== 8.2 특정 계정만 접속 허용 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --permanent --remove-service=ssh
vi /etc/ssh/sshd_config.d/10-custom.conf
firewall-cmd --reload
</syntaxhighlight>
</syntaxhighlight>


방화벽 상태 확인:
설정:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="apache">
firewall-cmd --list-all
AllowUsers admin
</syntaxhighlight>
</syntaxhighlight>


SSH 신규 포트 접속 확인 전에 기존 22번 포트를 먼저 차단하면 원격 접속이 불가능해질 수 있다.
여러 계정:


== 8. firewalld 기본 사용법 ==
<syntaxhighlight lang="apache">
AllowUsers admin operator backupuser
</syntaxhighlight>


Rocky Linux 9는 기본 방화벽 관리 도구로 firewalld를 사용한다.
그룹 기준:


일반적인 환경에서는 firewalld 사용을 권장한다.
<syntaxhighlight lang="apache">
AllowGroups wheel
</syntaxhighlight>


=== 8.1 firewalld 상태 확인 ===
문법 검사 및 적용:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl status firewalld
sshd -t
systemctl reload sshd
</syntaxhighlight>
</syntaxhighlight>


간단 확인:
== 9. SSH 포트 변경 ==
 
예시로 SSH 포트를 2222번으로 변경한다.
 
=== 9.1 SSH 설정 변경 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl is-active firewalld
vi /etc/ssh/sshd_config.d/10-custom.conf
systemctl is-enabled firewalld
</syntaxhighlight>
</syntaxhighlight>


=== 8.2 firewalld 시작 및 자동 시작 ===
<syntaxhighlight lang="apache">
 
Port 2222
<syntaxhighlight lang="bash">
systemctl enable --now firewalld
</syntaxhighlight>
</syntaxhighlight>


=== 8.3 활성 존 확인 ===
문법 검사:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --get-active-zones
sshd -t
</syntaxhighlight>
</syntaxhighlight>


기본 존 확인:
=== 9.2 SELinux 포트 등록 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --get-default-zone
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">
firewall-cmd --list-all
semanage port -m -t ssh_port_t -p tcp 2222
</syntaxhighlight>
</syntaxhighlight>


=== 8.4 서비스 단위 포트 허용 ===
=== 9.3 firewalld 포트 허용 ===
 
SSH 허용:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-port=2222/tcp
firewall-cmd --reload
firewall-cmd --reload
firewall-cmd --list-ports
</syntaxhighlight>
</syntaxhighlight>


HTTP 허용:
=== 9.4 SSH 재시작 및 확인 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --permanent --add-service=http
systemctl restart sshd
firewall-cmd --reload
systemctl status sshd
ss -lntp | grep 2222
</syntaxhighlight>
</syntaxhighlight>


HTTPS 허용:
새 포트 접속 테스트:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --permanent --add-service=https
ssh -p 2222 admin@192.168.10.20
firewall-cmd --reload
</syntaxhighlight>
</syntaxhighlight>


Samba 허용:
정상 접속 후 기존 22번 허용 제거:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --permanent --add-service=samba
firewall-cmd --permanent --remove-service=ssh
firewall-cmd --reload
firewall-cmd --reload
</syntaxhighlight>
</syntaxhighlight>


=== 8.5 포트 번호로 허용 ===
== 10. firewalld 기본 사용법 ==


TCP 8080 허용:
=== 10.1 상태 확인 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --permanent --add-port=8080/tcp
systemctl status firewalld
firewall-cmd --reload
systemctl is-active firewalld
systemctl is-enabled firewalld
</syntaxhighlight>
</syntaxhighlight>


UDP 514 허용:
시작:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --permanent --add-port=514/udp
systemctl enable --now firewalld
firewall-cmd --reload
</syntaxhighlight>
</syntaxhighlight>


TCP와 UDP를 모두 사용하는 경우 각각 등록한다.
=== 10.2 존 및 설정 확인 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --permanent --add-port=514/tcp
firewall-cmd --get-active-zones
firewall-cmd --permanent --add-port=514/udp
firewall-cmd --get-default-zone
firewall-cmd --reload
firewall-cmd --list-all
</syntaxhighlight>
</syntaxhighlight>


=== 8.6 허용 설정 제거 ===
=== 10.3 서비스 허용 ===
 
TCP 8080 제거:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --permanent --remove-port=8080/tcp
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>


HTTP 서비스 제거:
=== 10.4 포트 번호 허용 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --permanent --remove-service=http
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>


=== 8.7 런타임 설정과 영구 설정 차이 ===
=== 10.5 허용 설정 제거 ===
 
<code>--permanent</code> 옵션 없이 추가하면 현재 실행 중인 설정에만 반영된다.


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
firewall-cmd --add-port=8080/tcp
firewall-cmd --permanent --remove-port=8080/tcp
</syntaxhighlight>
firewall-cmd --permanent --remove-service=http
 
시스템 또는 firewalld 재시작 후 설정이 사라질 수 있다.
 
영구 설정:
 
<syntaxhighlight lang="bash">
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --reload
firewall-cmd --reload
</syntaxhighlight>
</syntaxhighlight>


=== 8.8 특정 IP에서만 SSH 허용 ===
=== 10.6 특정 IP 대역만 SSH 허용 ===
 
다음 예시는 <code>192.168.10.0/24</code> 대역에서만 TCP 22번 접근을 허용한다.
 
기존 SSH 서비스가 전체 대역에 허용되어 있다면 먼저 별도 콘솔을 확보한다.
 
Rich Rule 추가:


<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'
</syntaxhighlight>


기존 전체 SSH 허용 제거:
<syntaxhighlight lang="bash">
firewall-cmd --permanent --remove-service=ssh
firewall-cmd --permanent --remove-service=ssh
firewall-cmd --reload
firewall-cmd --reload
</syntaxhighlight>
설정 확인:
<syntaxhighlight lang="bash">
firewall-cmd --list-rich-rules
firewall-cmd --list-rich-rules
</syntaxhighlight>
</syntaxhighlight>


== 9. firewalld 비활성화 및 iptables 전환 ==
== 11. firewalld 비활성화 및 iptables 전환 ==


Rocky Linux 9에서는 firewalld 사용을 우선 권장한다.
Rocky Linux 9에서는 firewalld 사용을 우선 권장한다.


iptables 방식은 다음과 같은 경우에만 고려한다.
기존 운영 환경이 iptables 규칙으로 표준화된 경우에만 전환을 고려한다.
 
* 기존 운영 환경이 iptables 규칙으로 표준화되어 있는 경우
* 기존 스크립트가 iptables 명령어를 사용해야 하는 경우
* 애플리케이션 또는 운영 정책상 레거시 규칙 형식이 필요한 경우
 
Rocky Linux 9의 iptables 명령어는 내부적으로 nftables 호환 계층을 사용할 수 있다.
 
firewalld와 iptables 서비스를 동시에 운영하면 규칙 충돌이나 관리 혼선이 발생할 수 있으므로 한 가지 방식만 선택한다.


=== 9.1 현재 방화벽 규칙 백업 ===
=== 11.1 기존 방화벽 규칙 백업 ===
 
firewalld 설정 확인 및 백업:


<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
</syntaxhighlight>
현재 nftables 규칙 백업:
<syntaxhighlight lang="bash">
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>


원격 작업 중 방화벽 전환에 실패하면 SSH 접속이 차단될 수 있다.
=== 11.2 iptables 서비스 설치 ===
 
콘솔, iLO, iDRAC, IPMI 또는 가상화 콘솔을 확보한 상태에서 진행한다.
 
=== 9.2 iptables 서비스 패키지 설치 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
dnf install -y iptables-services
dnf install -y iptables-services
</syntaxhighlight>
설치 확인:
<syntaxhighlight lang="bash">
rpm -q iptables-services
rpm -q iptables-services
</syntaxhighlight>
</syntaxhighlight>


=== 9.3 firewalld 비활성화 ===
=== 11.3 firewalld 비활성화 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl disable --now firewalld
systemctl disable --now firewalld
</syntaxhighlight>
상태 확인:
<syntaxhighlight lang="bash">
systemctl is-active firewalld
systemctl is-active firewalld
systemctl is-enabled firewalld
systemctl is-enabled firewalld
</syntaxhighlight>
</syntaxhighlight>


예상 출력:
=== 11.4 iptables 기본 규칙 작성 ===
 
<syntaxhighlight lang="text">
inactive
disabled
</syntaxhighlight>
 
=== 9.4 iptables 기본 규칙 작성 ===
 
기존 파일 백업:
 
<syntaxhighlight lang="bash">
cp -a /etc/sysconfig/iptables \
/etc/sysconfig/iptables.bak.$(date +%Y%m%d_%H%M%S) 2>/dev/null
</syntaxhighlight>
 
설정 파일 편집:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
1,050번째 줄: 1,113번째 줄:
</syntaxhighlight>
</syntaxhighlight>


SSH 22번과 Samba를 허용하는 예시:
예시:


<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>


기본 정책이 DROP인 상태에서 SSH 허용 규칙이 누락되면 원격 접속이 차단된다.
=== 11.5 iptables 서비스 시작 ===
 
=== 9.5 iptables 서비스 시작 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl enable --now iptables
systemctl enable --now iptables
</syntaxhighlight>
상태 확인:
<syntaxhighlight lang="bash">
systemctl status iptables
systemctl status iptables
</syntaxhighlight>
규칙 확인:
<syntaxhighlight lang="bash">
iptables -L -n -v --line-numbers
iptables -L -n -v --line-numbers
</syntaxhighlight>
저장:
<syntaxhighlight lang="bash">
service iptables save
service iptables save
</syntaxhighlight>
</syntaxhighlight>


또는 현재 규칙을 파일로 저장한다.
또는:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
1,112번째 줄: 1,158번째 줄:
</syntaxhighlight>
</syntaxhighlight>


=== 9.6 규칙 테스트 ===
== 12. 서비스 정상 유무 확인 ==
 
SSH 포트 확인:
 
<syntaxhighlight lang="bash">
iptables -L INPUT -n -v --line-numbers | grep -E '22|2222'
</syntaxhighlight>
 
Samba 포트 확인:
 
<syntaxhighlight lang="bash">
iptables -L INPUT -n -v --line-numbers | grep -E '137|138|139|445'
</syntaxhighlight>
 
전체 규칙 확인:
 
<syntaxhighlight lang="bash">
iptables-save
</syntaxhighlight>
 
== 10. 서비스 정상 유무 확인 ==


=== 10.1 systemctl을 이용한 서비스 확인 ===
=== 12.1 systemctl 확인 ===
 
SSH 상태 확인:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl status sshd
systemctl status sshd
</syntaxhighlight>
Samba 상태 확인:
<syntaxhighlight lang="bash">
systemctl status smb
systemctl status smb
systemctl status nmb
systemctl status nmb
</syntaxhighlight>


실행 여부만 확인:
<syntaxhighlight lang="bash">
systemctl is-active sshd
systemctl is-active sshd
systemctl is-active smb
systemctl is-active smb
</syntaxhighlight>


부팅 시 자동 시작 여부 확인:
<syntaxhighlight lang="bash">
systemctl is-enabled sshd
systemctl is-enabled sshd
systemctl is-enabled smb
systemctl is-enabled smb
</syntaxhighlight>
</syntaxhighlight>


=== 10.2 실패한 서비스 확인 ===
=== 12.2 실패한 서비스 확인 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl --failed
systemctl --failed
</syntaxhighlight>
특정 서비스의 최근 로그 확인:
<syntaxhighlight lang="bash">
journalctl -u sshd -n 50 --no-pager
journalctl -u sshd -n 50 --no-pager
</syntaxhighlight>
Samba 로그 확인:
<syntaxhighlight lang="bash">
journalctl -u smb -n 50 --no-pager
journalctl -u smb -n 50 --no-pager
</syntaxhighlight>
</syntaxhighlight>


실시간 로그 확인:
=== 12.3 설정 문법 검사 ===
 
<syntaxhighlight lang="bash">
journalctl -u sshd -f
</syntaxhighlight>
 
=== 10.3 설정 파일 문법 검사 ===
 
SSH 설정 검사:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sshd -t
sshd -t
</syntaxhighlight>
Samba 설정 검사:
<syntaxhighlight lang="bash">
testparm
testparm
</syntaxhighlight>
</syntaxhighlight>


== 11. 서비스 포트 리스닝 확인 ==
== 13. 서비스 포트 리스닝 확인 ==
 
=== 11.1 ss 명령어 사용 ===
 
전체 TCP/UDP 리스닝 포트 확인:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ss -lntup
ss -lntup
</syntaxhighlight>
TCP 포트만 확인:
<syntaxhighlight lang="bash">
ss -lntp
ss -lntp
</syntaxhighlight>
UDP 포트만 확인:
<syntaxhighlight lang="bash">
ss -lnup
ss -lnup
</syntaxhighlight>
SSH 22번 확인:
<syntaxhighlight lang="bash">
ss -lntp | grep ':22'
ss -lntp | grep ':22'
</syntaxhighlight>
SSH 2222번 확인:
<syntaxhighlight lang="bash">
ss -lntp | grep ':2222'
ss -lntp | grep ':2222'
</syntaxhighlight>
Samba 포트 확인:
<syntaxhighlight lang="bash">
ss -lntup | grep -E ':137|:138|:139|:445'
ss -lntup | grep -E ':137|:138|:139|:445'
</syntaxhighlight>
</syntaxhighlight>


=== 11.2 결과에서 확인할 항목 ===
확인 항목:
 
출력 예시:
 
<syntaxhighlight lang="text">
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=1234,fd=3))
</syntaxhighlight>
 
확인할 항목:


{| class="wikitable"
{| class="wikitable"
|-
! 항목
! 항목
! 설명
|-
| LISTEN
| 연결 대기 상태
|-
| 0.0.0.0:22
| 모든 IPv4 인터페이스에서 수신
|-
| [::]:22
| 모든 IPv6 인터페이스에서 수신
|-
| 127.0.0.1
| 로컬 서버에서만 접근 가능
|-
| users
| 해당 포트를 사용하는 프로세스
|}


| ! 설명                      |
== 14. 외부에서 포트 오픈 여부 확인 ==
| -------------------------- |
| LISTEN                    |
| 해당 포트가 연결을 기다리는 상태        |
| -                          |
| 0.0.0.0:22                |
| 모든 IPv4 인터페이스에서 TCP 22번 수신 |
| -                          |
| [::]:22                    |
| 모든 IPv6 인터페이스에서 TCP 22번 수신 |
| -                          |
| 127.0.0.1                  |
| 로컬 서버에서만 접근 가능            |
| -                          |
| users                      |
| 해당 포트를 사용하는 프로세스          |
| }                          |


서비스가 실행 중이어도 포트가 리스닝하지 않으면 설정 오류 또는 프로세스 시작 실패를 의심해야 한다.
=== 14.1 Linux에서 nc 사용 ===
 
== 12. 외부에서 포트 오픈 여부 확인 ==
 
서버 내부의 <code>ss</code> 명령은 서비스 리스닝 여부를 확인한다.
 
방화벽과 네트워크를 포함한 실제 접근 가능 여부는 다른 PC에서 테스트해야 한다.
 
=== 12.1 nc 명령어 설치 ===
 
Rocky Linux에서 설치:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
dnf install -y nmap-ncat
dnf install -y nmap-ncat
</syntaxhighlight>
=== 12.2 TCP 포트 테스트 ===
SSH 22번 테스트:
<syntaxhighlight lang="bash">
nc -zv 192.168.10.20 22
nc -zv 192.168.10.20 22
</syntaxhighlight>
SSH 2222번 테스트:
<syntaxhighlight lang="bash">
nc -zv 192.168.10.20 2222
nc -zv 192.168.10.20 2222
</syntaxhighlight>
Samba 445번 테스트:
<syntaxhighlight lang="bash">
nc -zv 192.168.10.20 445
nc -zv 192.168.10.20 445
</syntaxhighlight>
</syntaxhighlight>


성공 예시:
=== 14.2 Windows PowerShell에서 확인 ===
 
<syntaxhighlight lang="text">
Connection to 192.168.10.20 22 port [tcp/ssh] succeeded!
</syntaxhighlight>
 
실패 유형:
 
{| class="wikitable"
! 메시지
 
| ! 의심 원인                      |
| ----------------------------- |
| Connection refused            |
| 서비스가 실행되지 않거나 해당 포트를 리스닝하지 않음 |
| -                            |
| Connection timed out          |
| 방화벽 차단, 라우팅 문제, 네트워크 단절      |
| -                            |
| No route to host              |
| 라우팅 또는 네트워크 경로 문제            |
| }                            |
 
=== 12.3 Windows PowerShell에서 테스트 ===


<syntaxhighlight lang="powershell">
<syntaxhighlight lang="powershell">
Test-NetConnection 192.168.10.20 -Port 22
Test-NetConnection 192.168.10.20 -Port 22
</syntaxhighlight>
SSH 포트가 2222번인 경우:
<syntaxhighlight lang="powershell">
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 접속 테스트 ==
 
<syntaxhighlight lang="text">
TcpTestSucceeded : True
</syntaxhighlight>
 
== 13. SSH 접속 테스트 ==
 
=== 13.1 Linux 또는 macOS에서 접속 ===


기본 포트:
기본 포트:
1,365번째 줄: 1,256번째 줄:
</syntaxhighlight>
</syntaxhighlight>


최초 접속 시 서버 호스트 키 확인 메시지가 표시될 수 있다.
SSH 장애 확인 순서:
 
<syntaxhighlight lang="text">
Are you sure you want to continue connecting (yes/no/[fingerprint])?
</syntaxhighlight>
 
서버 주소가 맞는지 확인한 후 다음을 입력한다.
 
<syntaxhighlight lang="text">
yes
</syntaxhighlight>
 
=== 13.2 Windows에서 SSH 접속 ===
 
Windows PowerShell 또는 명령 프롬프트에서 실행한다.
 
<syntaxhighlight lang="powershell">
ssh admin@192.168.10.20
</syntaxhighlight>
 
변경 포트:
 
<syntaxhighlight lang="powershell">
ssh -p 2222 admin@192.168.10.20
</syntaxhighlight>
 
PuTTY를 사용할 경우 다음 항목을 입력한다.
 
{| class="wikitable"
! 항목
 
| ! 값              |
| ---------------- |
| Host Name        |
| 192.168.10.20    |
| -                |
| Port            |
| 22 또는 변경한 SSH 포트 |
| -                |
| Connection Type  |
| SSH             |
| }                |
 
=== 13.3 SSH 접속 장애 확인 순서 ===


# 서버 IP 통신 확인
# 서버 IP 통신 확인
# SSH 서비스 상태 확인
# SSH 서비스 상태 확인
# SSH 설정 문법 확인
# SSH 설정 문법 확인
# SSH 포트 리스닝 확인
# SSH 포트 리스닝 확인
 
# 방화벽 규칙 확인
# firewalld 또는 iptables 규칙 확인
 
# SELinux 포트 등록 확인
# SELinux 포트 등록 확인
 
# SSH 로그 확인
# 서버 로그 확인
 
확인 명령어:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
1,436번째 줄: 1,276번째 줄:
</syntaxhighlight>
</syntaxhighlight>


== 14. SFTP 접속 테스트 ==
== 16. SFTP 접속 테스트 ==
 
SFTP는 FTP와 다른 프로토콜이다.
 
SFTP는 SSH 서비스를 이용하며 별도의 FTP 서버 프로그램이 필요하지 않다.
 
SSH 포트가 TCP 22번이면 SFTP도 TCP 22번을 사용한다.
 
SSH 포트를 2222번으로 변경하면 SFTP도 TCP 2222번을 사용한다.


=== 14.1 Linux에서 SFTP 접속 ===
SFTP는 SSH 서비스를 사용하며 별도 FTP 서버가 필요하지 않다.


기본 포트:
기본 포트:
1,460번째 줄: 1,292번째 줄:
</syntaxhighlight>
</syntaxhighlight>


SFTP에서 자주 사용하는 명령어:
주요 명령:


{| class="wikitable"
{| class="wikitable"
|-
! 명령어
! 명령어
! 설명
|-
| pwd
| 서버 현재 디렉터리
|-
| lpwd
| 로컬 현재 디렉터리
|-
| ls
| 서버 파일 목록
|-
| lls
| 로컬 파일 목록
|-
| get 파일명
| 파일 다운로드
|-
| put 파일명
| 파일 업로드
|-
| exit
| 종료
|}


| ! 설명              |
FileZilla 설정:
| ----------------- |
| pwd              |
| 서버의 현재 디렉터리 확인    |
| -                |
| lpwd              |
| 로컬 PC의 현재 디렉터리 확인 |
| -                |
| ls                |
| 서버 파일 목록 확인      |
| -                |
| lls              |
| 로컬 파일 목록 확인      |
| -                |
| cd                |
| 서버 디렉터리 이동        |
| -                |
| lcd              |
| 로컬 디렉터리 이동        |
| -                |
| get 파일명          |
| 서버 파일 다운로드        |
| -                |
| put 파일명          |
| 로컬 파일 업로드        |
| -                |
| exit              |
| SFTP 종료          |
| }                |
 
=== 14.2 Windows FileZilla에서 SFTP 접속 ===
 
FileZilla 사이트 관리자에서 다음과 같이 설정한다.


{| class="wikitable"
{| class="wikitable"
|-
! 항목
! 항목
! 설정값
|-
| 프로토콜
| SFTP - SSH File Transfer Protocol
|-
| 호스트
| 192.168.10.20
|-
| 포트
| 22 또는 변경한 SSH 포트
|-
| 사용자
| admin
|-
| 비밀번호
| 해당 계정 비밀번호
|}


| ! 설정값                            |
== 17. Samba 파일 공유 설정 ==
| --------------------------------- |
| 프로토콜                              |
| SFTP - SSH File Transfer Protocol |
| -                                |
| 호스트                              |
| 192.168.10.20                    |
| -                                |
| 포트                                |
| 22 또는 변경한 SSH 포트                  |
| -                                |
| 로그온 유형                            |
| 일반                                |
| -                                |
| 사용자                              |
| admin                            |
| -                                |
| 비밀번호                              |
| 해당 계정 비밀번호                        |
| }                                |
 
SFTP를 사용할 때 프로토콜을 FTP 또는 FTPS로 선택하면 접속되지 않는다.
 
=== 14.3 SFTP 업로드 권한 확인 ===
 
사용자 홈 디렉터리 권한 확인:
 
<syntaxhighlight lang="bash">
ls -ld /home/admin
</syntaxhighlight>
 
파일 생성 테스트:
 
<syntaxhighlight lang="bash">
sudo -u admin touch /home/admin/sftp-test.txt
</syntaxhighlight>
 
확인:
 
<syntaxhighlight lang="bash">
ls -l /home/admin/sftp-test.txt
</syntaxhighlight>


테스트 파일 삭제:
=== 17.1 Samba 설치 ===
 
<syntaxhighlight lang="bash">
rm -f /home/admin/sftp-test.txt
</syntaxhighlight>
 
== 15. Samba 파일 공유 설정 ==
 
Samba는 Linux 서버의 디렉터리를 Windows 네트워크 공유 방식으로 제공하는 서비스다.
 
Windows에서는 다음 형식으로 접근한다.
 
<syntaxhighlight lang="text">
\\192.168.10.20\share
</syntaxhighlight>
 
=== 15.1 Samba 패키지 설치 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
dnf install -y samba samba-client
dnf install -y samba samba-client
</syntaxhighlight>
설치 확인:
<syntaxhighlight lang="bash">
rpm -q samba
rpm -q samba
rpm -q samba-client
rpm -q samba-client
</syntaxhighlight>
</syntaxhighlight>


=== 15.2 공유용 계정 생성 ===
=== 17.2 공유 계정 생성 ===
 
Linux 계정 생성:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
useradd -m shareuser
useradd -m shareuser
passwd shareuser
passwd shareuser
</syntaxhighlight>
Samba 비밀번호 등록:
<syntaxhighlight lang="bash">
smbpasswd -a shareuser
smbpasswd -a shareuser
</syntaxhighlight>
Samba 계정 활성화:
<syntaxhighlight lang="bash">
smbpasswd -e shareuser
smbpasswd -e shareuser
</syntaxhighlight>
등록된 Samba 사용자 확인:
<syntaxhighlight lang="bash">
pdbedit -L
pdbedit -L
</syntaxhighlight>
</syntaxhighlight>


Linux 계정 비밀번호와 Samba 비밀번호는 별도로 관리될 수 있다.
=== 17.3 공유 디렉터리 생성 ===
 
=== 15.3 공유 디렉터리 생성 ===
 
공유 경로 예시:
 
<syntaxhighlight lang="text">
/data/share
</syntaxhighlight>
 
디렉터리 생성:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mkdir -p /data/share
mkdir -p /data/share
</syntaxhighlight>
소유자 설정:
<syntaxhighlight lang="bash">
chown -R shareuser:shareuser /data/share
chown -R shareuser:shareuser /data/share
</syntaxhighlight>
권한 설정:
<syntaxhighlight lang="bash">
chmod 2770 /data/share
chmod 2770 /data/share
</syntaxhighlight>
권한 확인:
<syntaxhighlight lang="bash">
ls -ld /data/share
ls -ld /data/share
</syntaxhighlight>
</syntaxhighlight>


=== 15.4 Samba 설정 파일 백업 ===
=== 17.4 Samba 설정 백업 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
1,642번째 줄: 1,380번째 줄:
</syntaxhighlight>
</syntaxhighlight>


=== 15.5 Samba 기본 설정 ===
=== 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>


주요 설정 설명:
문법 검사:
 
{| class="wikitable"
! 항목
 
| ! 설명                      |
| -------------------------- |
| workgroup                  |
| Windows 작업 그룹 이름          |
| -                          |
| security = user            |
| 사용자 계정 기반 인증              |
| -                          |
| server min protocol = SMB2 |
| 오래된 SMB1 프로토콜 사용 방지        |
| -                          |
| path                      |
| 실제 공유 디렉터리 경로              |
| -                          |
| browseable                |
| 네트워크 검색 시 공유 표시 여부        |
| -                          |
| writable                  |
| 쓰기 허용 여부                  |
| -                          |
| valid users                |
| 공유에 접근할 수 있는 Samba 사용자    |
| -                          |
| create mask                |
| 새 파일의 기본 권한                |
| -                          |
| directory mask            |
| 새 디렉터리의 기본 권한              |
| }                          |
 
=== 15.6 Samba 설정 문법 확인 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
1,711번째 줄: 1,411번째 줄:
</syntaxhighlight>
</syntaxhighlight>


특정 설정 파일 검사:
=== 17.6 SELinux 설정 ===
 
<syntaxhighlight lang="bash">
testparm /etc/samba/smb.conf
</syntaxhighlight>
 
문법 오류가 있으면 서비스를 시작하기 전에 수정한다.
 
=== 15.7 SELinux 설정 ===
 
Samba가 공유 디렉터리에 접근할 수 있도록 SELinux 컨텍스트를 설정한다.
 
필요 도구 설치:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
dnf install -y policycoreutils-python-utils
dnf install -y policycoreutils-python-utils
</syntaxhighlight>
영구 컨텍스트 등록:


<syntaxhighlight lang="bash">
semanage fcontext -a -t samba_share_t "/data/share(/.*)?"
semanage fcontext -a -t samba_share_t "/data/share(/.*)?"
</syntaxhighlight>
실제 디렉터리에 적용:
<syntaxhighlight lang="bash">
restorecon -Rv /data/share
restorecon -Rv /data/share
</syntaxhighlight>
확인:


<syntaxhighlight lang="bash">
ls -ldZ /data/share
ls -ldZ /data/share
</syntaxhighlight>
</syntaxhighlight>


출력에 다음 타입이 포함되어 있는지 확인한다.
=== 17.7 Samba 서비스 시작 ===
 
<syntaxhighlight lang="text">
samba_share_t
</syntaxhighlight>
 
기존에 같은 경로의 SELinux 규칙이 이미 있는 경우 수정 옵션을 사용한다.
 
<syntaxhighlight lang="bash">
semanage fcontext -m -t samba_share_t "/data/share(/.*)?"
restorecon -Rv /data/share
</syntaxhighlight>
 
=== 15.8 Samba 서비스 시작 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl enable --now smb
systemctl enable --now smb
</syntaxhighlight>
NetBIOS 이름 검색이 필요한 환경에서는 <code>nmb</code>도 시작한다.
<syntaxhighlight lang="bash">
systemctl enable --now nmb
systemctl enable --now nmb
</syntaxhighlight>
서비스 상태 확인:
<syntaxhighlight lang="bash">
systemctl status smb
systemctl status smb
systemctl status nmb
systemctl status nmb
</syntaxhighlight>
</syntaxhighlight>


최신 Windows 환경에서 IP 주소 또는 DNS 이름으로 직접 접근하는 경우 <code>smb</code> 서비스만으로도 동작할 수 있다.
최신 Windows 환경에서 IP 주소 또는 DNS 이름으로 직접 접근하는 경우
smb 서비스만으로도 동작할 수 있다.


=== 15.9 firewalld에서 Samba 허용 ===
=== 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
</syntaxhighlight>
설정 확인:
<syntaxhighlight lang="bash">
firewall-cmd --list-services
firewall-cmd --list-services
</syntaxhighlight>
</syntaxhighlight>


상세 확인:
=== 17.9 Samba 포트 확인 ===
 
<syntaxhighlight lang="bash">
firewall-cmd --info-service=samba
</syntaxhighlight>
 
=== 15.10 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>
주요 Samba 포트:


{| class="wikitable"
{| class="wikitable"
|-
! 포트
! 포트
! 프로토콜
! 프로토콜
! 용도
|-
| 137
| UDP
| NetBIOS 이름 서비스
|-
| 138
| UDP
| NetBIOS 데이터그램
|-
| 139
| TCP
| NetBIOS 세션 서비스
|-
| 445
| TCP
| SMB 직접 통신
|}


| ! 용도          |
=== 17.10 서버 내부 테스트 ===
| -------------- |
| 137            |
| UDP            |
| NetBIOS 이름 서비스 |
| -              |
| 138            |
| UDP            |
| NetBIOS 데이터그램  |
| -              |
| 139            |
| TCP            |
| NetBIOS 세션 서비스 |
| -              |
| 445            |
| TCP            |
| SMB 직접 통신      |
| }              |
 
=== 15.11 서버 내부에서 Samba 공유 테스트 ===
 
공유 목록 확인:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
smbclient -L localhost -U shareuser
smbclient -L localhost -U shareuser
</syntaxhighlight>
공유 접속:
<syntaxhighlight lang="bash">
smbclient //localhost/share -U shareuser
smbclient //localhost/share -U shareuser
</syntaxhighlight>
</syntaxhighlight>


접속 후 파일 목록 확인:
=== 17.11 Windows에서 접속 ===
 
<syntaxhighlight lang="text">
ls
</syntaxhighlight>
 
테스트 파일 업로드:
 
<syntaxhighlight lang="text">
put test.txt
</syntaxhighlight>
 
종료:
 
<syntaxhighlight lang="text">
exit
</syntaxhighlight>
 
=== 15.12 Windows에서 Samba 접속 ===
 
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>


인증 창이 나오면 Samba 사용자 계정을 입력한다.
Windows 자격 증명 초기화:
 
<syntaxhighlight lang="text">
사용자 이름: shareuser
비밀번호: smbpasswd에서 등록한 비밀번호
</syntaxhighlight>
 
사용자 이름 인식 문제가 있으면 다음 형식으로 입력한다.
 
<syntaxhighlight lang="text">
rocky-file01\shareuser
</syntaxhighlight>
 
또는:
 
<syntaxhighlight lang="text">
.\shareuser
</syntaxhighlight>
 
=== 15.13 Windows 자격 증명 초기화 ===
 
잘못된 계정 정보가 저장된 경우 명령 프롬프트에서 기존 연결을 삭제한다.


<syntaxhighlight lang="batch">
<syntaxhighlight lang="batch">
1,904번째 줄: 1,496번째 줄:
</syntaxhighlight>
</syntaxhighlight>


특정 서버 연결만 삭제:
네트워크 드라이브 연결:
 
<syntaxhighlight lang="batch">
net use \\192.168.10.20\share /delete
</syntaxhighlight>
 
다시 연결:


<syntaxhighlight lang="batch">
<syntaxhighlight lang="batch">
1,916번째 줄: 1,502번째 줄:
</syntaxhighlight>
</syntaxhighlight>


=== 15.14 Samba 접속 장애 확인 순서 ===
=== 17.12 Samba 장애 확인 순서 ===
 
# 서버와 IP 통신 확인


# 서버 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
</syntaxhighlight>
SELinux 차단 로그 확인:
<syntaxhighlight lang="bash">
ausearch -m AVC -ts recent
ausearch -m AVC -ts recent
</syntaxhighlight>
</syntaxhighlight>


최근 Samba 로그 확인:
== 18. 전체 설정 최종 점검 ==
 
<syntaxhighlight lang="bash">
tail -n 100 /var/log/samba/log.smbd
</syntaxhighlight>
 
로그 파일은 Samba 설정이나 패키지 버전에 따라 위치가 다를 수 있다.
 
== 16. 전체 설정 최종 점검 ==


=== 16.1 시스템 정보 ===
=== 18.1 시스템 정보 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
1,974번째 줄: 1,537번째 줄:
</syntaxhighlight>
</syntaxhighlight>


=== 16.2 네트워크 ===
=== 18.2 네트워크 ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
1,984번째 줄: 1,547번째 줄:
</syntaxhighlight>
</syntaxhighlight>


=== 16.3 SSH ===
본딩 사용 시:
 
<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>


=== 16.4 방화벽 ===
=== 18.4 방화벽 ===


firewalld 사용 시:
firewalld 사용 시:
2,012번째 줄: 1,582번째 줄:
</syntaxhighlight>
</syntaxhighlight>


=== 16.5 Samba ===
=== 18.5 Samba ===


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
2,023번째 줄: 1,593번째 줄:
</syntaxhighlight>
</syntaxhighlight>


== 17. 구축 완료 후 권장 사항 ==
== 19. 구축 완료 후 권장 사항 ==


=== 17.1 불필요한 root 원격 로그인 차단 ===
=== 19.1 root 원격 로그인 차단 ===


<syntaxhighlight lang="apache">
<syntaxhighlight lang="apache">
2,031번째 줄: 1,601번째 줄:
</syntaxhighlight>
</syntaxhighlight>


=== 17.2 일반 관리자 계정 사용 ===
=== 19.2 관리자 계정 사용 ===
 
관리 계정을 <code>wheel</code> 그룹에 추가하고 필요할 때만 sudo를 사용한다.


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
2,039번째 줄: 1,607번째 줄:
</syntaxhighlight>
</syntaxhighlight>


=== 17.3 사용하지 않는 서비스 비활성화 ===
=== 19.3 불필요한 서비스 비활성화 ===
 
실행 중인 서비스 확인:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl --type=service --state=running
systemctl --type=service --state=running
</syntaxhighlight>
불필요한 서비스를 확인한 후 비활성화한다.
<syntaxhighlight lang="bash">
systemctl disable --now 서비스명
systemctl disable --now 서비스명
</syntaxhighlight>
</syntaxhighlight>


서비스 용도를 확인하지 않고 임의로 비활성화하면 시스템 기능에 문제가 발생할 수 있다.
=== 19.4 정기 업데이트 ===
 
=== 17.4 정기 업데이트 ===
 
업데이트 확인:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
dnf check-update
dnf check-update
</syntaxhighlight>
업데이트 적용:
<syntaxhighlight lang="bash">
dnf update -y
dnf update -y
</syntaxhighlight>
</syntaxhighlight>


커널 및 핵심 라이브러리 업데이트 후에는 재부팅이 필요할 수 있다.
=== 19.5 시간 동기화 확인 ===
 
=== 17.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>


=== 17.6 설정 파일 백업 ===
=== 19.6 주요 설정 백업 ===
 
주요 설정 파일:
 
<syntaxhighlight lang="text">
/etc/NetworkManager/system-connections/
/etc/hosts
/etc/hostname
/etc/ssh/sshd_config
/etc/ssh/sshd_config.d/
/etc/firewalld/
/etc/sysconfig/iptables
/etc/samba/smb.conf
</syntaxhighlight>
 
백업 예시:


<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>


== 18. 전체 작업 순서 요약 ==
== 20. 전체 작업 순서 요약 ==


<syntaxhighlight lang="text">
<syntaxhighlight lang="text">
2,119번째 줄: 1,655번째 줄:
2. 설치 후 패키지 업데이트
2. 설치 후 패키지 업데이트
3. 네트워크 인터페이스 확인
3. 네트워크 인터페이스 확인
4. 고정 IP 및 DNS 설정
4. 단일 NIC 또는 본딩 구성
5. 게이트웨이와 외부 통신 확인
5. 고정 IP 및 DNS 설정
6. 호스트 이름 설정
6. 필요 시 ifcfg 형식으로 변환
7. 관리자 계정 생성
7. 게이트웨이와 외부 통신 확인
8. SSH 서비스 확인
8. 호스트 이름 설정
9. root 직접 로그인 차단
9. 관리자 계정 생성
10. 필요 시 SSH 허용 계정 제한
10. SSH 서비스 확인
11. 필요 시 SSH 포트 변경
11. root 직접 로그인 차단
12. SELinux에 변경 포트 등록
12. 필요 시 SSH 허용 계정 제한
13. 방화벽 포트 허용
13. 필요 시 SSH 포트 변경
14. SSH와 SFTP 접속 테스트
14. SELinux에 변경 포트 등록
15. Samba 패키지 설치
15. 방화벽 포트 허용
16. Samba 계정 및 공유 디렉터리 생성
16. SSH와 SFTP 접속 테스트
17. Samba 설정 파일 작성
17. Samba 패키지 설치
18. SELinux 컨텍스트 설정
18. Samba 계정 및 공유 디렉터리 생성
19. Samba 방화벽 허용
19. Samba 설정 파일 작성
20. Windows에서 공유 접속 테스트
20. SELinux 컨텍스트 설정
21. 설정 파일 백업
21. Samba 방화벽 허용
22. Windows에서 공유 접속 테스트
23. 전체 설정 파일 백업
</syntaxhighlight>
</syntaxhighlight>


== 19. 빠른 점검 명령어 모음 ==
== 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 계열 운영체제를 처음 설치한 후 기본 서버로 사용하기 위한 초기 설정 절차를 단계별로 설명한다.

다음 순서로 진행한다.

  1. 운영체제 설치
  2. 설치 직후 기본 확인
  3. CLI에서 IP 주소 설정
  4. 네트워크 인터페이스 본딩 설정
  5. 구형 ifcfg 파일 형식 적용
  6. 호스트 이름 설정
  7. SSH 기본 설정
  8. SSH 특정 계정 접속 제한
  9. SSH 포트 변경
  10. firewalld 포트 허용
  11. firewalld 비활성화 및 iptables 전환
  12. 서비스 상태 및 포트 확인
  13. SSH 및 SFTP 접속 테스트
  14. Samba 파일 공유 설정
  15. 전체 설정 최종 점검

본 문서의 명령어는 기본적으로 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/iptables

12. 서비스 정상 유무 확인

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 smb

12.2 실패한 서비스 확인

systemctl --failed
journalctl -u sshd -n 50 --no-pager
journalctl -u smb -n 50 --no-pager

12.3 설정 문법 검사

sshd -t
testparm

13. 서비스 포트 리스닝 확인

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 445

14.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 445

15. SSH 접속 테스트

기본 포트:

ssh admin@192.168.10.20

변경 포트:

ssh -p 2222 admin@192.168.10.20

SSH 장애 확인 순서:

  1. 서버 IP 통신 확인
  2. SSH 서비스 상태 확인
  3. SSH 설정 문법 확인
  4. SSH 포트 리스닝 확인
  5. 방화벽 규칙 확인
  6. SELinux 포트 등록 확인
  7. 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-pager

16. 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-client

17.2 공유 계정 생성

useradd -m shareuser
passwd shareuser
smbpasswd -a shareuser
smbpasswd -e shareuser
pdbedit -L

17.3 공유 디렉터리 생성

mkdir -p /data/share
chown -R shareuser:shareuser /data/share
chmod 2770 /data/share
ls -ld /data/share

17.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

문법 검사:

testparm

17.6 SELinux 설정

dnf install -y policycoreutils-python-utils

semanage fcontext -a -t samba_share_t "/data/share(/.*)?"
restorecon -Rv /data/share

ls -ldZ /data/share

17.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-services

17.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 shareuser

17.11 Windows에서 접속

\\192.168.10.20\share

호스트 이름으로 접근:

\\rocky-file01\share

Windows 자격 증명 초기화:

net use * /delete /y

네트워크 드라이브 연결:

net use Z: \\192.168.10.20\share /user:shareuser

17.12 Samba 장애 확인 순서

  1. 서버 IP 통신 확인
  2. smb 서비스 상태 확인
  3. TCP 445 포트 리스닝 확인
  4. 방화벽 허용 확인
  5. Samba 설정 문법 확인
  6. Samba 계정 확인
  7. Linux 디렉터리 권한 확인
  8. SELinux 컨텍스트 확인
  9. 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 recent

18. 전체 설정 최종 점검

18.1 시스템 정보

cat /etc/os-release
hostnamectl
timedatectl

18.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 show

18.3 SSH

systemctl is-active sshd
systemctl is-enabled sshd
sshd -t
ss -lntp | grep sshd
journalctl -u sshd -n 30 --no-pager

18.4 방화벽

firewalld 사용 시:

systemctl is-active firewalld
firewall-cmd --get-active-zones
firewall-cmd --list-all

iptables 사용 시:

systemctl is-active iptables
iptables -L -n -v --line-numbers
iptables-save

18.5 Samba

systemctl is-active smb
systemctl is-enabled smb
testparm
pdbedit -L
ss -lntup | grep -E ':137|:138|:139|:445'
ls -ldZ /data/share

19. 구축 완료 후 권장 사항

19.1 root 원격 로그인 차단

PermitRootLogin no

19.2 관리자 계정 사용

usermod -aG wheel admin

19.3 불필요한 서비스 비활성화

systemctl --type=service --state=running
systemctl disable --now 서비스명

19.4 정기 업데이트

dnf check-update
dnf update -y

19.5 시간 동기화 확인

timedatectl
chronyc tracking
chronyc sources -v

서울 시간대 설정:

timedatectl set-timezone Asia/Seoul

19.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/null

20. 전체 작업 순서 요약

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 로그 확인 및 장애 분석