Suricata 설치 · 27 min read · Oct 09, 2025
Rocky Linux 9에서 Elastic Stack과 함께 Suricata IDS 설치 및 구성하는 방법

Suricata는 서버를 통해 흐르는 모든 인터넷 트래픽 패킷을 검사하고 처리하는 네트워크 모니터링 도구입니다. 로그 이벤트를 생성하고, 경고를 트리거하며, 의심스러운 활동을 감지할 경우 트래픽을 차단할 수 있습니다.
단일 머신에 Suricata를 설치하여 트래픽을 모니터링하거나 게이트웨이 호스트에 배포하여 연결된 다른 서버의 모든 수신 및 송신 트래픽을 스캔할 수 있습니다. Suricata를 Elasticsearch, Kibana 및 Filebeat와 결합하여 보안 정보 및 이벤트 관리(SIEM) 도구를 만들 수 있습니다.
이 튜토리얼에서는 Rocky Linux 9 서버에 Suricata IDS 및 ElasticStack을 설치합니다. 스택의 다양한 구성 요소는 다음과 같습니다:
- Elasticsearch: 서버의 보안 이벤트를 저장, 인덱싱, 상관 관계 및 검색합니다.
- Kibana: Elasticsearch에 저장된 로그를 표시합니다.
- Filebeat: Suricata의
eve.json로그 파일을 구문 분석하고 각 이벤트를 Elasticsearch로 전송하여 처리합니다. - Suricata: 의심스러운 이벤트에 대해 네트워크 트래픽을 스캔하고 유효하지 않은 패킷을 차단합니다.
튜토리얼은 두 부분으로 나뉘어 있으며, 첫 번째 부분에서는 Suricata를 설치하고 구성하는 방법을 다루고, 두 번째 부분에서는 Elastic Stack을 설치하고 구성하는 방법을 다룹니다.
튜토리얼에서는 Suricata와 Elastic 스택을 서로 다른 서버에 설치합니다.
전제 조건
- Elastic Stack과 Suricata를 호스팅하는 서버는 최소 4GB RAM과 2 CPU 코어를 가져야 합니다.
- 서버는 개인 IP 주소를 사용하여 통신할 수 있어야 합니다.
- 서버는 비 루트 sudo 사용자로 Rocky Linux 9를 실행해야 합니다.
- 서버는 업데이트되어야 합니다.
$ sudo dnf update - Kibana 대시보드에 어디서나 접근하고 싶다면 Suricata가 설치될 서버를 가리키는 도메인(
kibana.example.com)을 설정합니다. - 두 서버에 필수 패키지를 설치합니다.
$ sudo dnf install yum-utils nano curl wget policycoreutils-python-utils -y
PART 1
1단계 - Suricata 설치
Suricata를 설치하려면 Open Information Security Foundation(OISF)의 패키지 리포지토리를 서버에 추가해야 합니다.
$ sudo dnf install 'dnf-command(copr)'
$ sudo dnf copr enable @oisf/suricata-7.0첫 번째 명령은 dnf 패키지 설치 프로그램을 위한 커뮤니티 프로젝트(copr)를 활성화합니다. 두 번째 명령은 OISF 리포지토리를 시스템에 추가하도록 활성화합니다. suricata-7.0은 소프트웨어의 최신 안정 버전에 접근할 수 있도록 리포지토리를 활성화합니다. 프롬프트가 나타날 때마다 y와 ENTER를 누릅니다.
다음으로 EPEL 리포지토리를 추가합니다.
$ sudo dnf install -y epel-release dnf-plugins-coreSuricata를 설치합니다.
$ sudo dnf install -y suricataSuricata 서비스를 활성화합니다.
$ sudo systemctl enable suricata2단계 - Suricata 구성
Suricata는 /etc/suricata/suricata.yaml 파일에 구성을 저장합니다. Suricata의 기본 모드는 IDS(침입 탐지 시스템) 모드로, 트래픽이 기록만 되고 중단되지 않습니다. Suricata에 익숙하지 않은 경우 모드를 변경하지 않는 것이 좋습니다. 구성을 완료하고 더 많은 것을 배우면 IPS(침입 방지 시스템) 모드를 활성화할 수 있습니다.
커뮤니티 ID 활성화
커뮤니티 ID 필드는 서로 다른 모니터링 도구에서 생성된 레코드 간의 데이터 상관 관계를 쉽게 만듭니다. Suricata를 Elasticsearch와 함께 사용할 것이므로 커뮤니티 ID를 활성화하는 것이 유용할 수 있습니다.
편집을 위해 /etc/suricata/suricata.yaml 파일을 엽니다.
$ sudo nano /etc/suricata/suricata.yaml# Community Flow ID 줄을 찾아 변수 community-id의 값을 true로 설정합니다.
. . .
# Community Flow ID
# Adds a 'community_id' field to EVE records. These are meant to give
# records a predictable flow ID that can be used to match records to
# output of other tools such as Zeek (Bro).
#
# Takes a 'seed' that needs to be same across sensors and tools
# to make the id less predictable.
# enable/disable the community id feature.
community-id: true
. . .프롬프트가 나타날 때 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다.
이제 이벤트에는 1:S+3BA2UmrHK0Pk+u3XH78GAFTtQ=와 같은 ID가 포함되어 있어 서로 다른 모니터링 도구 간의 데이터 세트를 일치시키는 데 사용할 수 있습니다.
네트워크 인터페이스 선택
기본 Suricata 구성 파일은 eth0 장치/네트워크 인터페이스의 트래픽을 검사합니다. 서버가 다른 네트워크 인터페이스를 사용하는 경우 구성에서 이를 업데이트해야 합니다.
다음 명령을 사용하여 네트워크 인터페이스의 장치 이름을 확인합니다.
$ ip -p -j route show default다음과 같은 출력을 받게 됩니다.
[ {
"dst": "default",
"gateway": "172.31.1.1",
"dev": "eth0",
"protocol": "dhcp",
"prefsrc": "65.108.61.177",
"metric": 100,
"flags": [ ]
} ]dev 변수는 네트워킹 장치를 나타냅니다. 출력에서 eth0가 네트워킹 장치로 표시됩니다. 시스템에 따라 출력이 다를 수 있습니다.
장치 이름을 알았으니 구성 파일을 엽니다.
$ sudo nano /etc/suricata/suricata.yamlaf-packet: 줄을 찾아 약 580번째 줄에 있습니다. 그 아래에 시스템의 장치 이름으로 변수 interface의 값을 설정합니다.
# Linux high speed capture support
af-packet:
- interface: eth0
# Number of receive threads. "auto" uses the number of cores
#threads: auto
# Default clusterid. AF_PACKET will load balance packets based on flow.
cluster-id: 99
. . .추가 인터페이스를 추가하려면 약 650번째 줄의 af-packet 섹션 하단에 추가하면 됩니다.
새 인터페이스를 추가하려면 아래와 같이 - interface: default 섹션 바로 위에 삽입합니다.
# For eBPF and XDP setup including bypass, filter and load balancing, please
# see doc/userguide/capture-hardware/ebpf-xdp.rst for more info.
- interface: enp0s1
cluster-id: 98
...
- interface: default
#threads: auto
#use-mmap: no
#tpacket-v3: yes예제에서는 새 인터페이스 enp0s1와 cluster-id 변수에 대한 고유 값을 추가했습니다. 추가하는 각 인터페이스에는 고유한 클러스터 ID를 포함해야 합니다.
pcap: 줄을 찾아 그 아래에 시스템의 장치 이름으로 변수의 값을 설정합니다.
# Cross platform libpcap capture support
pcap:
- interface: eth0
# On Linux, pcap will try to use mmap'ed capture and will use "buffer-size"
# as total memory used by the ring. So set this to something bigger
# than 1% of your bandwidth.새 인터페이스를 추가하려면 이전과 같이 - interface: default 섹션 바로 위에 삽입합니다.
- interface: enp0s1
# Put default values here
- interface: default
#checksum-checks: auto작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다.
라이브 규칙 다시 로드
규칙을 추가, 제거 및 편집할 때마다 Suricata를 다시 시작해야 합니다. 그러나 기본적으로 활성화되어 있으므로 아무것도 할 필요는 없습니다.
라이브 다시 로딩이 활성화되면 다음 명령을 사용하여 Suricata 프로세스를 다시 시작하지 않고도 규칙을 다시 로드할 수 있습니다.
$ sudo kill -usr2 $(pidof suricata)$(pidof suricata) 플래그는 Suricata 프로세스의 프로세스 ID를 찾습니다. kill 명령의 -usr2 부분은 Suricata 프로세스에 SIGUSR2 신호를 보냅니다. SIGUSR2 신호는 Suricata와 함께 규칙을 다시 로드하도록 구성되어 있습니다.
디렉토리 권한 구성
Suricata는 설치 과정에서 suricata라는 시스템 사용자 및 그룹을 자동으로 생성했습니다. 설치가 제대로 작동하도록 디렉토리 권한을 적절하게 설정해야 합니다.
다음 명령을 실행하여 Suricata의 디렉토리에 대한 그룹을 suricata로 설정합니다.
$ sudo chgrp -R suricata /etc/suricata
$ sudo chgrp -R suricata /var/lib/suricata
$ sudo chgrp -R suricata /var/log/suricata 읽기 및 쓰기를 위한 그룹 권한을 설정합니다.
$ sudo chmod -R g+r /etc/suricata/
$ sudo chmod -R g+rw /var/lib/suricata
$ sudo chmod -R g+rw /var/log/suricata현재 사용자를 Suricata 그룹에 추가
Suricata는 설치 과정에서 suricata라는 시스템 사용자 및 그룹을 자동으로 생성했습니다. 현재 사용자 이름을 suricata 그룹에 추가하여 sudo 없이 직접 작업을 수행할 수 있습니다.
$ sudo usermod -a -G suricata $USER새 그룹 멤버십을 적용하려면 서버에서 로그아웃한 후 다시 로그인하거나 다음을 입력합니다.
$ su - ${USER}계속하려면 사용자 비밀번호를 입력하라는 메시지가 표시됩니다.
다음 명령을 입력하여 사용자가 이제 suricata 그룹에 추가되었는지 확인합니다.
$ id -nG
username wheel suricata3단계 - Suricata 규칙 구성
Suricata는 기본적으로 네트워크 트래픽을 감지하기 위해 제한된 규칙 세트만 사용합니다. suricata-update라는 도구를 사용하여 외부 공급자로부터 더 많은 규칙 세트를 추가할 수 있습니다. 다음 명령을 실행하여 추가 규칙을 포함합니다.
$ suricata-update
14/4/2024 -- 01:32:58 - -- Using data-directory /var/lib/suricata.
14/4/2024 -- 01:32:58 - -- Using Suricata configuration /etc/suricata/suricata.yaml
14/4/2024 -- 01:32:58 - -- Using /usr/share/suricata/rules for Suricata provided rules.
14/4/2024 -- 01:32:58 - -- Found Suricata version 7.0.4 at /usr/sbin/suricata.
.....
14/4/2024 -- 01:32:58 - -- No sources configured, will use Emerging Threats Open
14/4/2024 -- 01:32:58 - -- Fetching https://rules.emergingthreats.net/open/suricata-7.0.4/emerging.rules.tar.gz.
100% - 4243799/4243799
14/4/2024 -- 01:33:00 - -- Done.
14/4/2024 -- 01:33:00 - -- Loading distribution rule file /usr/share/suricata/rules/app-layer-events.rules
.....
14/4/2024 -- 01:33:04 - -- Writing rules to /var/lib/suricata/rules/suricata.rules: total: 48646; enabled: 37144; added: 48646; removed 0; modified: 0
14/4/2024 -- 01:33:04 - -- Writing /var/lib/suricata/rules/classification.config
14/4/2024 -- 01:33:04 - -- Testing with suricata -T.
14/4/2024 -- 01:33:41 - -- Done. 규칙 세트 공급자 추가
Suricata의 규칙을 확장하려면 더 많은 공급자를 추가할 수 있습니다. 무료 및 상업적 공급자로부터 규칙을 가져올 수 있습니다.
다음 명령을 사용하여 기본 공급자 목록을 나열할 수 있습니다.
$ suricata-update list-sources예를 들어 tgreen/hunting 규칙 세트를 포함하려면 다음 명령으로 활성화할 수 있습니다.
$ suricata-update enable-source tgreen/hunting
14/4/2024 -- 01:37:07 - -- Using data-directory /var/lib/suricata.
14/4/2024 -- 01:37:07 - -- Using Suricata configuration /etc/suricata/suricata.yaml
14/4/2024 -- 01:37:07 - -- Using /usr/share/suricata/rules for Suricata provided rules.
14/4/2024 -- 01:37:07 - -- Found Suricata version 7.0.4 at /usr/sbin/suricata.
14/4/2024 -- 01:37:07 - -- Source index does not exist, will use bundled one.
14/4/2024 -- 01:37:07 - -- Please run suricata-update update-sources.
14/4/2024 -- 01:37:07 - -- Creating directory /var/lib/suricata/update/sources
14/4/2024 -- 01:37:07 - -- Enabling default source et/open
14/4/2024 -- 01:37:07 - -- Source tgreen/hunting enabled suricata-update 명령을 다시 실행하여 새 규칙을 다운로드하고 업데이트합니다. Suricata는 기본적으로 재시작 없이 규칙 변경을 처리할 수 있습니다.
4단계 - Suricata 구성 검증
Suricata는 구성 파일 및 규칙에 대한 오류를 확인하는 검증 도구를 제공합니다. 다음 명령을 실행하여 검증 도구를 실행합니다.
$ suricata -T -c /etc/suricata/suricata.yaml -v
Notice: suricata: This is Suricata version 7.0.4 RELEASE running in SYSTEM mode
Info: cpu: CPUs/cores online: 2
Info: suricata: Running suricata under test mode
Info: suricata: Setting engine mode to IDS mode by default
Info: exception-policy: master exception-policy set to: auto
Info: logopenfile: fast output device (regular) initialized: fast.log
Info: logopenfile: eve-log output device (regular) initialized: eve.json
Info: logopenfile: stats output device (regular) initialized: stats.log
Info: detect: 1 rule files processed. 37144 rules successfully loaded, 0 rules failed, 0
Info: threshold-config: Threshold config parsed: 0 rule(s) found
Info: detect: 37147 signatures processed. 1194 are IP-only rules, 4892 are inspecting packet payload, 30849 inspect application layer, 108 are decoder event only
Notice: suricata: Configuration provided was successfully loaded. Exiting.-T 플래그는 Suricata가 테스트 모드에서 실행되도록 지시하고, -c 플래그는 구성 파일의 위치를 설정하며, -v 플래그는 명령의 자세한 출력을 인쇄합니다. 시스템 구성 및 추가된 규칙 수에 따라 명령이 완료되는 데 몇 분이 걸릴 수 있습니다.
5단계 - Suricata 실행
이제 Suricata가 구성되고 설정되었으므로 애플리케이션을 실행할 시간입니다.
$ sudo systemctl start suricata프로세스의 상태를 확인합니다.
$ sudo systemctl status suricata모든 것이 올바르게 작동하면 다음 출력을 볼 수 있습니다.
? suricata.service - Suricata Intrusion Detection Service
Loaded: loaded (/usr/lib/systemd/system/suricata.service; enabled; preset: disabled)
Active: active (running) since Sun 2024-04-14 01:45:43 UTC; 4s ago
Docs: man:suricata(1)
Process: 6081 ExecStartPre=/bin/rm -f /var/run/suricata.pid (code=exited, status=0/SUCCESS)
Main PID: 6082 (Suricata-Main)
Tasks: 1 (limit: 22569)
Memory: 111.8M
CPU: 4.318s
CGroup: /system.slice/suricata.service
??6082 /sbin/suricata -c /etc/suricata/suricata.yaml --pidfile /var/run/suricata.pid -i eth0 --user suricata
Apr 14 01:45:43 suricata systemd[1]: Starting Suricata Intrusion Detection Service...
Apr 14 01:45:43 suricata systemd[1]: Started Suricata Intrusion Detection Service.
Apr 14 01:45:43 suricata suricata[6082]: i: suricata: This is Suricata version 7.0.4 RELEASE running in SYSTEM mode서비스 상태에서 다음과 같은 오류가 표시될 수 있습니다.
Apr 15 02:20:13 suricata suricata[5554]: E: logopenfile: Error opening file: "/var/log/suricata//fast.log": Permission denied
Apr 15 02:20:13 suricata suricata[5554]: W: runmodes: output module "fast": setup failed
Apr 15 02:20:13 suricata suricata[5554]: E: logopenfile: Error opening file: "/var/log/suricata//eve.json": Permission denied
Apr 15 02:20:13 suricata suricata[5554]: W: runmodes: output module "eve-log": setup failed
Apr 15 02:20:13 suricata suricata[5554]: E: logopenfile: Error opening file: "/var/log/suricata//stats.log": Permission denied
Apr 15 02:20:13 suricata suricata[5554]: W: runmodes: output module "stats": setup failed권한을 다시 설정해야 합니다.
$ sudo chown -R suricata:suricata /var/log/suricataSuricata 서비스를 다시 시작합니다.
$ sudo systemctl restart suricata프로세스가 모든 규칙을 파싱하는 데 몇 분이 걸릴 수 있습니다. 따라서 위의 상태 확인은 Suricata가 준비되었는지 여부를 완전히 나타내지 않습니다. 다음 명령을 사용하여 로그 파일을 모니터링할 수 있습니다.
$ sudo tail -f /var/log/suricata/suricata.log다음과 같은 줄이 표시되면 Suricata가 실행 중이며 네트워크 트래픽을 모니터링할 준비가 된 것입니다.
[5577 - Suricata-Main] 2024-04-15 02:22:52 Info: exception-policy: master exception-policy set to: auto
[5577 - Suricata-Main] 2024-04-15 02:22:52 Info: ioctl: eth0: MTU 1500
[5577 - Suricata-Main] 2024-04-15 02:22:52 Info: privs: dropped the caps for main thread
[5577 - Suricata-Main] 2024-04-15 02:22:52 Info: conf: Running in live mode, activating unix socket
[5577 - Suricata-Main] 2024-04-15 02:22:52 Info: logopenfile: fast output device (regular) initialized: fast.log
[5577 - Suricata-Main] 2024-04-15 02:22:52 Info: logopenfile: eve-log output device (regular) initialized: eve.json
[5577 - Suricata-Main] 2024-04-15 02:22:52 Info: logopenfile: stats output device (regular) initialized: stats.log
[5577 - Suricata-Main] 2024-04-15 02:23:03 Info: detect: 1 rule files processed. 37144 rules successfully loaded, 0 rules failed, 0
[5577 - Suricata-Main] 2024-04-15 02:23:03 Info: threshold-config: Threshold config parsed: 0 rule(s) found
[5577 - Suricata-Main] 2024-04-15 02:23:04 Info: detect: 37147 signatures processed. 1194 are IP-only rules, 4892 are inspecting packet payload, 30849 inspect application layer, 108 are decoder event only
[5577 - Suricata-Main] 2024-04-15 02:23:32 Info: runmodes: eth0: creating 2 threads
[5577 - Suricata-Main] 2024-04-15 02:23:32 Info: unix-manager: unix socket '/var/run/suricata/suricata-command.socket'
[5577 - Suricata-Main] 2024-04-15 02:23:32 Notice: threads: Threads created -> W: 2 FM: 1 FR: 1 Engine started.출력을 종료하려면 Ctrl + C를 누릅니다.
6단계 - Suricata 규칙 테스트
Suricata가 의심스러운 트래픽을 감지하는지 확인합니다. Suricata 가이드는 다음 명령을 사용하여 ET Open 규칙 번호 2100498을 테스트할 것을 권장합니다.
$ curl http://testmynids.org/uid/index.html다음과 같은 응답을 받게 됩니다.
uid=0(root) gid=0(root) groups=0(root)위 명령은 손상된 시스템에서 실행할 수 있는 id 명령의 출력을 반환하는 것처럼 가장합니다. Suricata가 트래픽을 감지했는지 확인하려면 지정된 규칙 번호를 사용하여 로그 파일을 확인해야 합니다.
$ grep 2100498 /var/log/suricata/fast.logIPv6를 사용한 경우 다음과 같은 출력을 보게 됩니다.
02/22/2022-23:24:33.997371 [] [1:2100498:7] GPL ATTACK_RESPONSE id check returned root [] [Classification: Potentially Bad Traffic] [Priority: 2] {TCP} 2600:9000:2204:5c00:0018:30b3:e400:93a1:80 -> 2a03:b0c0:0002:00d0:0000:0000:0fc2:b001:41468IPv4를 사용한 경우 다음과 같은 출력을 보게 됩니다.
02/22/2022-23:21:46.783476 [] [1:2100498:7] GPL ATTACK_RESPONSE id check returned root [] [Classification: Potentially Bad Traffic] [Priority: 2] {TCP} 204.246.178.81:80 -> 164.90.192.1:36364Suricata는 또한 JSON 형식으로 /var/log/suricata/eve.log 파일에 이벤트를 기록합니다. 이러한 규칙을 읽고 해석하려면 jq를 설치해야 하며, 이는 이 튜토리얼의 범위를 벗어납니다.
PART 2
Suricata를 설치하고 테스트한 튜토리얼의 첫 번째 부분이 완료되었습니다. 다음 부분에서는 ELK 스택을 설치하고 Suricata 및 해당 로그를 시각화하도록 설정합니다. 튜토리얼의 두 번째 부분은 별도로 지정되지 않는 한 두 번째 서버에서 수행해야 합니다.
7단계 - Elasticsearch 및 Kibana 설치
Elasticsearch 설치의 첫 번째 단계는 Elastic GPG 키를 서버에 추가하는 것입니다.
$ sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearchElasticsearch 패키지를 위한 리포지토리를 생성하려면 /etc/yum/yum.repos.d/elasticsearch.repo 파일을 생성하고 열어 편집합니다.
$ sudo nano /etc/yum.repos.d/elasticsearch.repo다음 코드를 붙여넣습니다.
[elasticsearch]
name=Elasticsearch repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md프롬프트가 나타날 때 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다.
Elasticsearch와 Kibana를 설치합니다.
$ sudo dnf install --enablerepo=elasticsearch elasticsearch kibana리포지토리를 기본적으로 비활성화했기 때문에 매번 --enablerepo=elasticsearch 플래그를 사용해야 합니다. 이렇게 하면 이러한 패키지가 우발적으로 업그레이드되는 것을 방지합니다.
Elasticsearch 설치 시 다음과 같은 출력을 받게 됩니다.
--------------------------- Security autoconfiguration information ------------------------------
Authentication and authorization are enabled.
TLS for the transport and HTTP layers is enabled and configured.
The generated password for the elastic built-in superuser is : ilc+Gju=gZTxQHI4cSkF
If this node should join an existing cluster, you can reconfigure this with
'/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token '
after creating an enrollment token on your existing cluster.
You can complete the following actions at any time:
Reset the password of the elastic built-in superuser with
'/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic'.
Generate an enrollment token for Kibana instances with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana'.
Generate an enrollment token for Elasticsearch nodes with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node'.
------------------------------------------------------------------------------------------------- 다음 명령을 사용하여 서버의 개인 IP 주소를 찾습니다.
$ ip -brief address show
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0 UP 37.27.84.123/32 2a01:4f9:c012:db02::1/64 fe80::9400:3ff:fe34:d589/64
eth1 UP 10.0.0.2/32 fe80::8400:ff:fe84:5baf/64서버의 개인 IP(이 경우 10.0.0.2)를 적어두십시오. 나머지 튜토리얼에서는 이를 your_private_IP로 참조합니다. 서버의 공용 IP 주소(37.27.84.123)는 나머지 튜토리얼에서 your_public_IP로 참조됩니다. 또한 서버의 네트워크 이름 eth1도 적어두십시오.
8단계 - Elasticsearch 구성
Elasticsearch는 /etc/elasticsearch/elasticsearch.yml 파일에 구성을 저장합니다. 편집을 위해 파일을 엽니다.
$ sudo nano /etc/elasticsearch/elasticsearch.ymlElasticsearch는 기본적으로 로컬 연결만 허용합니다. Kibana가 개인 IP 주소를 통해 접근할 수 있도록 변경해야 합니다.
#network.host: 192.168.0.1 줄을 찾아 그 아래에 다음 줄을 추가합니다.
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 192.168.0.1
network.bind_host: ["127.0.0.1", "your_private_IP"]
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:이렇게 하면 Elastic이 여전히 로컬 연결을 수용하면서 Kibana가 개인 IP 주소를 통해 접근할 수 있도록 합니다.
다음 단계는 몇 가지 보안 기능을 활성화하고 Elastic이 단일 노드에서 실행되도록 구성하는 것입니다. 이를 위해 파일의 끝에 다음 줄을 추가합니다.
. . .
discovery.type: single-node여러 Elasticsearch 노드를 사용할 경우 생략할 수 있습니다.
또한 다음 줄의 주석을 해제하여 해시(#)를 추가합니다.
#cluster.initial_master_nodes: ["elastic"]작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다.
JVM 힙 크기 구성
Elasticsearch를 시작하기 전에 Elasticsearch에서 사용하는 메모리를 구성해야 합니다. /etc/elasticsearch/jvm.options.d/jvm-heap.options 파일을 생성하고 열어 편집합니다.
$ sudo nano /etc/elasticsearch/jvm.options.d/jvm-heap.options다음 줄을 붙여넣습니다.
-Xms3g
-Xmx3g작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다. 여기서는 Elasticsearch에 3GB의 공간을 할당합니다. 서버 크기에 따라 값을 선택하십시오.
방화벽 구성
Elasticsearch가 개인 네트워크를 통해 접근할 수 있도록 적절한 방화벽 규칙을 추가합니다.
$ sudo firewall-cmd --permanent --zone=internal --change-interface=eth1
$ sudo firewall-cmd --permanent --zone=internal --add-service=elasticsearch
$ sudo firewall-cmd --permanent --zone=internal --add-service=kibana
$ sudo firewall-cmd --permanent --add-port=5601/tcp
$ sudo firewall-cmd --reload첫 번째 명령에서 인터페이스 이름을 선택할 때 7단계에서 얻은 것과 같은 이름을 선택해야 합니다. 위의 명령은 방화벽의 기본 영역을 내부로 변경하고 Elasticsearch에 대해 포트 9200 및 9300, Kibana에 대해 포트 5601을 엽니다.
Elasticsearch 시작
이제 Elasticsearch를 구성했으므로 서비스를 시작할 시간입니다.
시스템 데몬을 다시 로드합니다.
$ sudo systemctl daemon-reloadElasticsearch 서버를 활성화하고 시작합니다.
$ sudo systemctl enable elasticsearch --now서비스 상태를 확인합니다.
$ sudo systemctl status elasticsearch
? elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; preset: disabled)
Active: active (running) since Sun 2024-04-14 03:51:12 UTC; 1min 20s ago
Docs: https://www.elastic.co
Main PID: 5987 (java)
Tasks: 74 (limit: 22569)
Memory: 3.4G
CPU: 50.532s
CGroup: /system.slice/elasticsearch.serviceElasticsearch 비밀번호 생성
Elasticsearch의 보안 설정을 활성화한 후 다음 단계는 Elasticsearch 슈퍼유저의 비밀번호를 생성하는 것입니다. 설치 중에 제공된 기본 비밀번호를 사용할 수 있지만 수정하는 것이 좋습니다.
다음 명령을 실행하여 Elasticsearch 비밀번호를 재설정합니다. 강력한 비밀번호를 선택하십시오.
$ sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic -i
This tool will reset the password of the [elastic] user.
You will be prompted to enter the password.
Please confirm that you would like to continue [y/N]y
Enter password for [elastic]:
Re-enter password for [elastic]:
Password for the [elastic] user successfully reset. 이제 Elasticsearch가 쿼리에 응답하는지 테스트해 보겠습니다.
$ sudo curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic https://localhost:9200
Enter host password for user 'elastic':
{
"name" : "elastic",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "VSP7LEZURF6SR8I1BPF9RQ",
"version" : {
"number" : "8.13.2",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "16cc90cd2d08a3147ce02b07e50894bc060a4cbf",
"build_date" : "2024-04-05T14:45:26.420424304Z",
"build_snapshot" : false,
"lucene_version" : "9.10.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}이것은 Elasticsearch가 완전히 기능하고 원활하게 실행되고 있음을 확인합니다.
9단계 - Kibana 구성
Kibana를 구성하는 첫 번째 단계는 Elasticsearch 인증서를 Kibana 디렉토리에 복사하는 것입니다.
$ sudo cp /etc/elasticsearch/certs/http_ca.crt /etc/kibana/다음으로, xpack 보안 기능을 활성화하여 비밀 키를 생성합니다. Kibana는 이 비밀 키를 사용하여 Elasticsearch에 데이터를 저장합니다. 비밀 키를 생성하는 유틸리티는 /usr/share/kibana/bin 디렉토리에서 액세스할 수 있습니다.
$ sudo /usr/share/kibana/bin/kibana-encryption-keys generate -q-q 플래그는 명령 지침을 억제합니다. 다음과 같은 출력을 받게 됩니다.
xpack.encryptedSavedObjects.encryptionKey: fdce3576894a0a7b12a639a40f643acd
xpack.reporting.encryptionKey: 92f426be0f487b7d8dd191b86443f2a6
xpack.security.encryptionKey: 34bf00781dbe85d1dcd99dc94ef1c9b7출력을 복사합니다.
/etc/kibana/kibana.yml에서 Kibana의 구성 파일을 열어 편집합니다.
$ sudo nano /etc/kibana/kibana.yml이전 명령에서 복사한 코드를 파일 끝에 붙여넣습니다.
. . .
# Maximum number of documents loaded by each shard to generate autocomplete suggestions.
# This value must be a whole number greater than zero. Defaults to 100_000
#unifiedSearch.autocomplete.valueSuggestions.terminateAfter: 100000
xpack.encryptedSavedObjects.encryptionKey: fdce3576894a0a7b12a639a40f643acd
xpack.reporting.encryptionKey: 92f426be0f487b7d8dd191b86443f2a6
xpack.security.encryptionKey: 34bf00781dbe85d1dcd99dc94ef1c9b7Kibana 호스트 구성
Kibana가 서버의 개인 IP 주소에서 접근 가능하도록 구성해야 합니다. 파일에서 #server.host: "localhost" 줄을 찾아 그 아래에 다음 줄을 추가합니다.
# Kibana is served by a back end server. This setting specifies the port to use.
#server.port: 5601
# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
#server.host: "localhost"
server.host: "your_private_IP"텔레메트리 끄기
Kibana는 기본적으로 데이터를 서버에 다시 전송합니다. 이는 성능에 영향을 미칠 수 있으며 개인 정보 위험이 있습니다. 따라서 텔레메트리를 끄는 것이 좋습니다. 텔레메트리를 끄기 위해 파일 끝에 다음 코드를 추가합니다. 첫 번째 설정은 텔레메트리를 끄고 두 번째 설정은 Kibana의 고급 설정 섹션에서 첫 번째 설정을 덮어쓰지 못하도록 합니다.
telmetry.optIn: false
telmetry.allowChangingOptInStatus: falseSSL 구성
변수 elasticsearch.ssl.certificateAuthorities를 찾아 주석을 해제하고 값을 다음과 같이 변경합니다.
elasticsearch.ssl.certificateAuthorities: [ "/etc/kibana/http_ca.crt" ]작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다.
Kibana 접근 구성
다음 단계는 나중에 Kibana 웹 인터페이스에 로그인하는 데 사용할 수 있는 등록 토큰을 생성하는 것입니다.
$ sudo /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
eyJ2ZXIiOiI4LjEzLjIiLCJhZHIiOlsiMzcuMjcuODQuMTIzOjkyMDAiXSwiZmdyIjoiMmI2ZjhhOWRiOWJjMDU5NDk0NGE0OGFkMjMxODg2NzYxNTViZGViN2U5YjY4MmY3N2MzYmI3ZDk2Nzc3YjY0NyIsImtleSI6InppVU0zSTRCOE5lSHBLU3k2T0owOnBLNHJiWjBZVHYybWNTbmxrTXlqbncifQ==Kibana 시작
Kibana에 대한 보안 접근 및 네트워킹을 구성했으므로 프로세스를 시작하고 활성화합니다.
$ sudo systemctl enable kibana --now실행 중인지 확인하려면 상태를 확인합니다.
$ sudo systemctl status kibana
? kibana.service - Kibana
Loaded: loaded (/usr/lib/systemd/system/kibana.service; enabled; preset: disabled)
Active: active (running) since Sun 2024-04-14 04:25:54 UTC; 963ms ago
Docs: https://www.elastic.co
Main PID: 6464 (node)
Tasks: 7 (limit: 22569)
Memory: 48.2M
CPU: 1.238s
CGroup: /system.slice/kibana.service
??6464 /usr/share/kibana/bin/../node/bin/node /usr/share/kibana/bin/../src/cli/dist
Apr 14 04:25:54 elastic systemd[1]: Started Kibana.
.....10단계 - Kibana 대시보드 접근
Kibana는 Elasticsearch에 개인 IP 주소를 통해서만 접근할 수 있도록 구성되었으므로 두 가지 방법으로 접근할 수 있습니다. 첫 번째 방법은 PC에서 Elasticsearch 서버로 SSH 터널을 사용하는 것입니다. 이렇게 하면 PC의 포트 5601이 서버의 개인 IP 주소로 포워딩되며, PC의 브라우저에서 http://localhost:5601로 Kibana에 접근할 수 있습니다. 그러나 이 방법은 다른 곳에서 접근할 수 없음을 의미합니다.
두 번째 방법은 Suricata 서버에 Nginx를 설치하고 이를 역방향 프록시로 사용하여 Elasticsearch 서버에 개인 IP 주소를 통해 접근하는 것입니다. 두 가지 방법 모두 논의할 것입니다. 요구 사항에 따라 둘 중 하나를 선택할 수 있습니다.
SSH 로컬 터널 사용
Windows 10 또는 Windows 11을 사용하는 경우 Windows Powershell에서 SSH LocalTunnel을 실행할 수 있습니다. Linux 또는 macOS에서는 터미널을 사용할 수 있습니다. SSH 접근을 구성해야 할 수도 있습니다.
다음 명령을 컴퓨터의 터미널에서 실행하여 SSH 터널을 생성합니다.
$ ssh -L 5601:your_private_IP:5601 navjot@your_public_IP -N-L플래그는 로컬 SSH 터널을 나타내며, 이는 PC의 포트에서 서버로 트래픽을 포워딩합니다.private_IP:5601은 서버에서 트래픽이 포워딩되는 IP 주소입니다. 이 경우 Elasticsearch 서버의 개인 IP 주소로 교체합니다.your_public_IP는 SSH 연결을 열기 위해 사용되는 Elasticsearch 서버의 공용 IP 주소입니다.-N플래그는 OpenSSH에 명령을 실행하지 말고 터널이 실행되는 동안 연결을 유지하라고 지시합니다.
이제 터널이 열렸으므로 PC의 브라우저에서 http://localhost:5601 URL을 열어 Kibana에 접근할 수 있습니다. 다음 화면이 표시됩니다.

명령을 실행하는 동안 터널을 열어 두어야 합니다. 터널을 닫으려면 터미널에서 Ctrl + C를 누릅니다.
Nginx 역방향 프록시 사용
이 방법은 전 세계 어디에서나 대시보드에 접근하고 싶을 때 가장 적합합니다. 모든 명령은 Elasticsearch 서버에서 실행해야 합니다.
Nginx 설치
Rocky Linux 9에는 이전 버전의 Nginx가 포함되어 있습니다. 최신 버전을 설치하려면 공식 Nginx 리포지토리를 사용해야 합니다.
/etc/yum.repos.d/nginx.repo 파일을 생성하고 열어 편집합니다.
$ sudo nano /etc/yum.repos.d/nginx.repo다음 코드를 붙여넣습니다.
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다. 우리는 Nginx의 메인라인 버전을 사용할 것이므로 위 파일에서 메인라인 섹션 아래에 enabled=1을 사용하여 메인라인 리포를 활성화했습니다. 둘 중 하나를 선택할 수 있습니다.
Nginx를 설치합니다.
$ sudo dnf install -y nginx설치를 확인합니다.
$ nginx -v
nginx version: nginx/1.25.4Nginx 서버 서비스를 활성화하고 시작합니다.
$ sudo systemctl enable nginx --now방화벽 구성
더 진행하기 전에 방화벽에서 HTTP 및 HTTPS 포트를 열어야 합니다.
$ sudo firewall-cmd --permanent --add-service=http
$ sudo firewall-cmd --permanent --add-service=https변경 사항을 적용하려면 방화벽을 다시 로드합니다.
$ sudo firewall-cmd --reloadSSL 설치 및 구성
첫 번째 단계는 Let’s Encrypt SSL 인증서를 설치하는 것입니다. 이를 위해 먼저 EPEL 리포지토리를 설치해야 합니다.
$ sudo dnf install -y epel-releaseCertbot 및 해당 Nginx 플러그인을 설치합니다.
$ sudo dnf install -y certbot python3-certbot-nginx도메인 kibana.example.com에 대한 SSL 인증서를 생성합니다.
$ sudo certbot certonly --nginx --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m [email protected] -d kibana.example.com위 명령은 서버의 /etc/letsencrypt/live/kibana.example.com 디렉토리에 인증서를 다운로드합니다.
Diffie-Hellman 그룹 인증서를 생성합니다.
$ sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 4096Certbot 자동 갱신 타이머를 활성화하고 시작합니다.
$ sudo systemctl enable certbot-renew.timer
$ sudo systemctl start certbot-renew.timer타이머 목록을 확인합니다.
$ sudo systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
---------------------------------------------------------------------------------------------------------------------------------
Mon 2024-04-15 00:00:00 UTC 19min left Sun 2024-04-14 08:20:34 UTC 15h ago logrotate.timer logrotate.service
Mon 2024-04-15 00:43:16 UTC 1h 2min left Sun 2024-04-14 09:01:33 UTC 14h ago fstrim.timer fstrim.service
Mon 2024-04-15 00:44:47 UTC 1h 4min left Sun 2024-04-14 23:30:19 UTC 10min ago dnf-makecache.timer dnf-makecache.service
Mon 2024-04-15 06:52:31 UTC 7h left - - certbot-renew.timer certbot-renew.service프로세스가 잘 작동하는지 확인하기 위해 드라이런을 수행합니다.
$ sudo certbot renew --dry-run오류가 없으면 모든 설정이 완료됩니다. 인증서는 자동으로 갱신됩니다.
Nginx 구성
Kibana에 대한 Nginx 구성 파일을 생성하고 엽니다.
$ sudo nano /etc/nginx/conf.d/kibana.conf다음 코드를 붙여넣습니다. Elasticsearch 서버의 개인 IP 주소로 교체합니다.
server {
listen 80; listen [::]:80;
server_name kibana.example.com;
return 301 https://$host$request_uri;
}
server {
server_name kibana.example.com;
charset utf-8;
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
http3 on;
quic_retry on;
access_log /var/log/nginx/kibana.access.log;
error_log /var/log/nginx/kibana.error.log;
ssl_certificate /etc/letsencrypt/live/kibana.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/kibana.example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/kibana.example.com/chain.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
ssl_prefer_server_ciphers off;
resolver 8.8.8.8;
ssl_stapling on;
ssl_stapling_verify on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
location / {
proxy_pass http://your_private_IP:5601;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다.
/etc/nginx/nginx.conf 파일을 열어 편집합니다.
$ sudo nano /etc/nginx/nginx.confinclude /etc/nginx/conf.d/*.conf; 줄 앞에 다음 줄을 추가합니다.
server_names_hash_bucket_size 64;작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다.
구성을 확인합니다.
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successfulNginx 서비스를 시작합니다.
$ sudo systemctl start nginx그런 다음 Kibana의 구성에서 기본 URL 필드를 추가해야 합니다.
Kibana의 구성 파일을 엽니다.
$ sudo nano /etc/kibana/kibana.yml주석 처리된 줄 #server.publicBaseUrl: ""를 찾아 해시를 제거하여 다음과 같이 변경합니다.
server.publicBaseUrl: "https://kibana.example.com"작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다.
Kibana 서비스를 재시작합니다.
$ sudo systemctl restart kibanaSELinux를 구성하여 Nginx 활성화
외부 호스트에 대한 연결을 허용하는 정책을 적용합니다.
$ sudo setsebool -P httpd_can_network_connect 1Kibana로 Elasticsearch 구성 완료
몇 분 기다린 후 브라우저에서 https://kibana.example.com URL을 로드합니다.
등록 토큰 필드가 표시됩니다. 9단계에서 생성한 등록 토큰을 입력합니다.

Configure Elastic 버튼을 클릭하여 진행합니다. 다음으로 확인 코드가 요청됩니다.
Elasticsearch 터미널로 돌아가 다음 명령을 실행하여 코드를 생성합니다. 이 코드를 페이지에 입력하고 Verify 버튼을 클릭하여 진행합니다.
$ sudo /usr/share/kibana/bin/kibana-verification-code
Your verification code is: 232 001
다음으로 Elastic 설정이 완료될 때까지 기다립니다. 몇 분이 걸릴 수 있습니다.

다음으로 로그인 화면으로 리디렉션됩니다.

11단계 - Filebeat 설치 및 구성
Filebeat는 Suricata 서버에 설치할 것입니다. 따라서 Suricata 서버로 돌아가 Elastic GPG 키를 추가하여 시작합니다.
$ sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearchElastic 리포지토리를 생성하고 엽니다.
$ sudo nano /etc/yum.repos.d/elasticsearch.repo다음 코드를 붙여넣습니다.
[elasticsearch]
name=Elasticsearch repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다.
Filebeat를 설치합니다.
$ sudo dnf install --enablerepo=elasticsearch filebeatFilebeat를 구성하기 전에 Elasticsearch 서버에서 http_ca.crt 파일을 Filebeat 서버로 복사해야 합니다. Filebeat 서버에서 다음 명령을 실행합니다.
$ scp username@your_public_ip:/etc/elasticsearch/certs/http_ca.crt /etc/filebeatFilebeat는 /etc/filebeat/filebeat.yml 파일에 구성을 저장합니다. 편집을 위해 엽니다.
$ sudo nano /etc/filebeat/filebeat.yml가장 먼저 Kibana 대시보드에 연결해야 합니다. Kibana 섹션에서 #host: "localhost:5601" 줄을 찾아 그 아래에 다음 줄을 추가합니다.
. . .
# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:
# Kibana Host
# Scheme and port can be left out and will be set to the default (http and 5601)
# In case you specify and additional path, the scheme is required: http://localhost:5601/path
# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
#host: "localhost:5601"
host: "your_private_IP:5601"
protocol: "http"
ssl.enabled: true
ssl.certificate_authorities: ["/etc/filebeat/http_ca.crt"]
. . .다음으로 파일의 Elasticsearch Output 섹션을 찾아 hosts, username, password 값을 다음과 같이 편집합니다. 사용자 이름은 elastic으로 설정하고 비밀번호는 이 튜토리얼 8단계에서 생성한 값을 사용합니다. 또한 protocol을 HTTPS로 설정합니다.
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["your_private_IP:9200"]
# Performance preset - one of "balanced", "throughput", "scale",
# "latency", or "custom".
preset: balanced
# Protocol - either `http` (default) or `https`.
protocol: "https"
# Authentication credentials - either API key or username/password.
#api_key: "id:api_key"
username: "elastic"
password: ""
ssl.certificate_authorities: ["/etc/filebeat/http_ca.crt"]
ssl.verification_mode: full 파일의 맨 아래에 다음 줄을 추가합니다.
setup.ilm.overwrite: true작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다. Filebeat가 Elasticsearch에 연결할 수 있도록 Elasticsearch의 SSL 정보를 Filebeat에 전달하는 마지막 단계가 필요합니다.
Filebeat에서 Elasticsearch 서버로의 연결을 테스트합니다. Elasticsearch 비밀번호를 입력하라는 메시지가 표시됩니다.
$ sudo curl -v --cacert /etc/filebeat/http_ca.crt https://your_private_ip:9200 -u elastic다음과 같은 출력을 받게 됩니다.
Enter host password for user 'elastic':
* Trying 10.0.0.2:9200...
* Connected to 10.0.0.2 (10.0.0.2) port 9200 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* CAfile: /etc/filebeat/http_ca.crt
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS header, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS header, Finished (20):
* TLSv1.2 (IN), TLS header, Unknown (23):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (OUT), TLS header, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS header, Unknown (23):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: CN=elastic
* start date: Apr 14 08:37:21 2024 GMT
* expire date: Apr 14 08:37:21 2026 GMT
* subjectAltName: host "10.0.0.2" matched cert's IP address!
* issuer: CN=Elasticsearch security auto-configuration HTTP CA
* SSL certificate verify ok.
* Server auth using Basic with user 'elastic'
* TLSv1.2 (OUT), TLS header, Unknown (23):
> GET / HTTP/1.1
> Host: 10.0.0.2:9200
> Authorization: Basic ZWxhc3RpYzpsaWZlc3Vja3M2NjIwMDI=
> User-Agent: curl/7.76.1
> Accept: */*
>
* TLSv1.2 (IN), TLS header, Unknown (23):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.2 (IN), TLS header, Unknown (23):
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< X-elastic-product: Elasticsearch
< content-type: application/json
< content-length: 532
<
{
"name" : "elastic",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "vnUn8l1bQ1qkF-VjCoiWmQ",
"version" : {
"number" : "8.13.2",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "16cc90cd2d08a3147ce02b07e50894bc060a4cbf",
"build_date" : "2024-04-05T14:45:26.420424304Z",
"build_snapshot" : false,
"lucene_version" : "9.10.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
* Connection #0 to host 10.0.0.2 left intact이제 Filebeat의 내장 Suricata 모듈을 활성화합니다.
$ sudo filebeat modules enable suricata
Enabled suricata/etc/filebeat/modules.d/suricata.yml 파일을 열어 편집합니다.
$ sudo nano /etc/filebeat/modules.d/suricata.yml파일을 다음과 같이 편집합니다. enabled 변수의 값을 true로 변경해야 합니다. 또한 var.paths 변수를 주석 해제하고 값을 다음과 같이 설정합니다.
# Module: suricata
# Docs: https://www.elastic.co/guide/en/beats/filebeat/8.10/filebeat-module-suricata.html
- module: suricata
# All logs
eve:
enabled: true
# Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths: ["/var/log/suricata/eve.json"]작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다.
Filebeat 구성을 마무리하는 마지막 단계는 filebeat setup 명령을 사용하여 SIEM 대시보드 및 파이프라인을 Elasticsearch에 로드하는 것입니다.
$ sudo filebeat setup명령이 완료되는 데 몇 분이 걸릴 수 있습니다. 완료되면 다음과 같은 출력을 받게 됩니다.
Index setup finished.
Loading dashboards (Kibana must be running and reachable)
Loaded dashboards
Loaded Ingest pipelinesFilebeat 서비스를 시작하고 활성화합니다.
$ sudo systemctl enable filebeat --now서비스 상태를 확인합니다.
$ sudo systemctl status filebeat
? filebeat.service - Filebeat sends log files to Logstash or directly to Elasticsearch.
Loaded: loaded (/usr/lib/systemd/system/filebeat.service; enabled; preset: disabled)
Active: active (running) since Sun 2024-04-14 10:12:51 UTC; 31s ago
Docs: https://www.elastic.co/beats/filebeat
Main PID: 7299 (filebeat)
Tasks: 8 (limit: 22569)
Memory: 407.2M
CPU: 7.640s
CGroup: /system.slice/filebeat.service
??7299 /usr/share/filebeat/bin/filebeat --environment systemd -c /etc/filebeat/filebeat.yml --path.home /usr/share/filebeat --path.config /etc/filebeat.......... 12단계 - Kibana 대시보드 관리
https://kibana.example.com을 열면 다시 로그인 화면으로 이동합니다.

사용자 이름 elastic와 이전에 생성한 비밀번호로 로그인하면 다음 화면이 표시됩니다.

Explore on my own 링크를 클릭하여 대시보드로 진행합니다.

상단의 검색 상자에 type:data suricata를 입력하여 Suricata의 정보를 찾습니다.

첫 번째 결과([Filebeat Suricata] Alert Overview)를 클릭하면 유사한 화면이 표시됩니다. 기본적으로 마지막 15분 동안의 항목만 표시되지만, 더 많은 데이터를 보여주기 위해 더 긴 시간 동안 표시합니다.

Events 버튼을 클릭하여 모든 기록된 이벤트를 봅니다.

이벤트 및 경고 페이지를 스크롤하면 프로토콜 유형, 출처 및 목적지 포트, 출처의 IP 주소로 각 이벤트 및 경고를 식별할 수 있습니다. 트래픽이 발생한 국가도 볼 수 있습니다.
Kibana와 Filebeat를 사용하여 다른 유형의 대시보드에 접근하고 생성할 수 있습니다. 즉시 사용할 수 있는 유용한 내장 대시보드 중 하나는 보안 대시보드입니다. 왼쪽 햄버거 메뉴에서 Security 대시보드를 클릭하고 Explore를 선택한 다음 오른쪽에서 Network 대시보드를 선택합니다.

다음 페이지가 표시됩니다.

Nginx와 같은 다른 대시보드를 추가하려면 내장된 Filebeat 모듈을 활성화하고 구성하면 됩니다.
결론
이로써 Rocky Linux 9 서버에서 Elastic Stack과 함께 Suricata IDS를 설치하고 구성하는 튜토리얼이 완료되었습니다. Kibana 대시보드에 외부에서 접근할 수 있도록 Nginx를 역방향 프록시로 구성했습니다. 질문이 있으면 아래 댓글에 남겨주세요.
새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.