리눅스 FirewallD 설치 및 데몬 설정

리눅스 FirewallD는 iptables의 체인과 정책이라는 규칙 대신 Zone과 Service를 대신 사용합니다. Firewalld를 사용하는 이유는 iptables의 규칙이 복잡하기 때문에 iptables 대신 사용할 수 있도록 하기 위함입니다.

  • 리눅스 Firewalld 특징
  • iptables는 재설정 시 기존 세션이 끊어지지만 Firewalld는 기존 세션을 유지하면서 업데이트가 가능합니다.
  • Zone과 Service를 사용

✅ 리눅스 FirewallD 설치하기

리눅스 서버에 설치 여부를 먼저 확인합니다.

rpm -qa | grep firewalld

설치되어 있지 않다면 아무 것도 나오지 않습니다.

# dnf: 록키 리눅스 | yum CentOS
dnf -y install firewalld
Last metadata expiration check: 0:37:56 ago on Sun Jan  7 12:34:52 2024.
Dependencies resolved.
==========================================================================================================================================================================================================
 Package                                                 Architecture                              Version                                             Repository                                    Size
==========================================================================================================================================================================================================
Installing:
 firewalld                                               noarch                                    1.2.5-2.el9_3                                       baseos                                       446 k
Installing dependencies:
 firewalld-filesystem                                    noarch                                    1.2.5-2.el9_3                                       baseos                                       8.2 k
 ipset                                                   x86_64                                    7.11-8.el9                                          baseos                                        42 k
 ipset-libs                                              x86_64                                    7.11-8.el9                                          baseos                                        69 k
 iptables-nft                                            x86_64                                    1.8.8-6.el9_1                                       baseos                                       185 k
 libnftnl                                                x86_64                                    1.2.2-1.el9                                         baseos                                        83 k
 nftables                                                x86_64                                    1:1.0.4-11.el9_3                                    baseos                                       398 k
 python3-firewall                                        noarch                                    1.2.5-2.el9_3                                       baseos                                       348 k
 python3-nftables                                        x86_64                                    1:1.0.4-11.el9_3                                    baseos                                        19 k
Installing weak dependencies:
 libcap-ng-python3                                       x86_64                                    0.8.2-7.el9                                         appstream                                     29 k

Transaction Summary
==========================================================================================================================================================================================================
Install  10 Packages

Total download size: 1.6 M

✅ 리눅스 Firewalld 데몬 시작

# firewalld 서비스를 시작
systemctl start firewalld
# firewalld 서비스 중지
systemctl stop firewalld
# firewalld 서비스 활성화(재부팅)
systemctl enable firewalld
# 설정 후 설정 즉시 로드
firewall-cmd --reload

### firewalld 방화벽 상태 확인 ###
systemctl status firewalld
## 상태 조회 중 메시지 확인 시 AllowZoneDrifting가 yes로 설정되어 있는 경우 나오는 메시지 
WARNING: AllowZoneDrifting is enabled. This is considered an insecure configur...t now.
vi /etc/firewalld/firewalld.conf
AllowZoneDrifting=yes
no로  두는 것이 좋다는.. 
systemctl firewalld restart 
AllowZoneDrifting 참조

✅ firewalld zone 설정 확인

  • firewalld 옵션
  • –permanent : 영구적으로 실행(default zone에 등록)
  • –add-service: 서비스 추가
  • –remove-service 서비스 삭제
# 기본 설정 ZONE 확인
~]# firewall-cmd --get-default-zone
publi
# 네트워크 인터페이스에서 사용하는 영역 확인
firewall-cmd --get-active-zones
public
  interfaces: eth0
# 특정 영역의 모든 구성 확인
firewall-cmd --zone=public --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources: 
  services: cockpit dhcpv6-client ssh
  ports: 
  protocols: 
  forward: yes
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
# 모든 영역의 모든 구성 확인
firewall-cmd --list-all-zones
 firewall-cmd --list-all-zones
block
  target: %%REJECT%%
  icmp-block-inversion: no
  interfaces: 
  sources: 
  services: 
  ports: 
  protocols: 
  forward: yes
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

dmz
  target: default
  icmp-block-inversion: no
  interfaces: 
  sources: 
  services: ssh
  ports: 
  protocols: 
  forward: yes
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

drop
  target: DROP
----- 이하 생략 -----

✅ firewalld zone 설정하기

1. 포트 설정

# 포트 허용하기: 임의 3391 포트 허용 및 거부 | permanent(영구적인)로 영구 설정
firewall-cmd --zone=public --add-port=3391/tcp
firewall-cmd --zone=public --add-port=3391/tcp --permanent 
 
firewall-cmd --zone=public --remove-port=3391/tcp --permanent
# 설정 후 설정 즉시 로드
firewall-cmd --reload
# 설정된 포트 보기
firewall-cmd --zone=public --list-ports

2. IP 설정

### IP대역에 대해 방화벽 해제하기
# 추가(접근 허용) 하기
firewall-cmd --permanent --add-source=192.168.0.0/24
# 제거하기
firewall-cmd --permanent --remove-source=192.168.0.0/24
## 특정 IP 접근 허용
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address=210.192.3.118 reject' 
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address==210.192.3.118 drop'   
# 설정된 방화벽 리스트 보기
firewall-cmd --zone=public --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources: 
  services: cockpit dhcpv6-client ssh
  ports: 3391/tcp
  protocols: 
  forward: yes
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
	rule family="ipv4" source address="192.168.0.0/24" port port="8000" protocol="tcp" accept

3. http, https 서비스 추가 및 해제

# 서비스 추가
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
# 서비스 해제
sudo firewall-cmd --permanent --remove-service=http
sudo firewall-cmd --permanent --remove-service=http

리눅스 FirewallD 설치 및 운영 방법에 대해 간단히 알아 봤습니다.

리눅스Linux(회색 배경의 나무 큐브)

Similar Posts

  • VirtualBox 복제 후 CentOS 7 네트워크 인터페이스 중복 문제 해결

    VirtualBox에 CentOS 7을 설치 후 복제 기능을 이용해서 CentOS 7을 복제 했습니다. 여기서 네트워크 인터페이스 중복 문제가 발생하여, 이 내용에 대해 확인해 봤습니다. 목차✅ 리눅스 FirewallD 설치하기✅ 리눅스 Firewalld 데몬 시작✅ firewalld zone 설정 확인✅ firewalld zone 설정하기1. 포트 설정2. IP 설정3. http, https 서비스 추가 및 해제✅ 네트워크 인터페이스 중복 기존에 설정했던…

  • 리눅스 free 명령어: 메모리 상태 확인

    리눅스 free 명령어는 서버의 메모리 사용량과 여유 사용량을 확인할 수 있는 명령어로 /proc/meminfo의 메모리 정보를 가져와 보여줍니다. 목차✅ 리눅스 FirewallD 설치하기✅ 리눅스 Firewalld 데몬 시작✅ firewalld zone 설정 확인✅ firewalld zone 설정하기1. 포트 설정2. IP 설정3. http, https 서비스 추가 및 해제✅ 리눅스 free 명령어 옵션 1. free -h 설명 2. 옵션 활용…

  • 리눅스 YUM 개념과 기본 명령어

    YUM(Yellow dog Updater, Modified)은 레드햇(RPM) 계열 리눅스 배포판에서 사용되는 패키지 설치 및 관리 도구입니다. 기존의 RPM 방식은 패키지 설치 시 의존성 문제로 사용자가 필요한 도구를 일일이 설치해야 하는 번거로움이 있었습니다. YUM은 이러한 의존성 문제를 자동으로 해결해 주며, 필요한 패키지와 관련된 의존 패키지를 함께 설치하여 오류를 최소화합니다. 의존성이 존재할 때 관련된 다른 패키지들을 자동으로…

  • [Linux] 리눅스 vi 명령어 정리 | Vim 3가지 모드 및 비주얼 모드

    리눅스 터미널에서 ‘.txt’, ‘.conf’ 등의 ASCII 파일을 편집하기 위해 vi 편집기 명령어를 사용합니다. vi 편집기는 명령모드 입력모드와 저장 및 종료 후 치환하는 리눅스 vi 명령어는 익숙해지면 매우 빠른 작업이 가능하기 때문에 효율적인 업무를 진행할 수 있습니다. 목차✅ 리눅스 FirewallD 설치하기✅ 리눅스 Firewalld 데몬 시작✅ firewalld zone 설정 확인✅ firewalld zone 설정하기1. 포트 설정2….

  • SSH 명령어: 옵션 및 사용 방법

    리눅스에서 SSH(Secure Shell)는 네트워크를 통해 다른 시스템에 안전하게 접속할 수 있도록 해주는 프로토콜입니다. SSH는 원격 서버와 클라이언트 간의 통신을 암호화하여 보안성을 높이며, 주로 원격 접속, 파일 전송, 그리고 터널링 기능을 제공합니다. SSH 명령어를 사용하여 사용자는 원격 서버에 안전하게 접속한 뒤 다양한 작업을 수행할 수 있습니다. 터널링 기능: 한 네트워크에서 다른 네트워크로 데이터를 안전하게…

  • 리눅스: RPM, YUM 차이

    RPM(Red Hat Package Manager)과 YUM(Yellowdog Updater, Modified)은 리눅스의 패키지를 설치하는 인스톨 프로그램입니다. 패키지 설치와 삭제, 업데이트를 관리하는 명령어입니다. 목차✅ 리눅스 FirewallD 설치하기✅ 리눅스 Firewalld 데몬 시작✅ firewalld zone 설정 확인✅ firewalld zone 설정하기1. 포트 설정2. IP 설정3. http, https 서비스 추가 및 해제RPM 리눅스를 초기에 설치 할 때는 tar, gzip 등의 확장자를 사용했습니다….

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Prove your humanity: 4   +   2   =