CentOS Stream 10

Elastic Stack 9 : Packetbeat インストール2025/08/08

 

ネットワークパケット情報のデータ収集機能を提供する Packetbeat をインストールします。

[1] Packetbeat をインストールします。 事前に Elasticsearch リポジトリ設定済みであることが前提です。
[root@dlp ~]#
dnf -y install packetbeat
[2] 基本的な設定をして Packetbeat を起動します。
[root@dlp ~]#
vi /etc/packetbeat/packetbeat.yml
# 58行目 : 収集する項目を設定
# ICMPv4/ICMPv6 を無効にする場合は false に設定
# 44行目以降 : デフォルトで多くのポートが監視対象となっているが
# 無効にする場合は [ports: ***] をコメントアウト

packetbeat.protocols:
- type: icmp
  # Enable ICMPv4 and ICMPv6 monitoring. Default: false
  enabled: true

- type: amqp
  # Configure the ports where to listen for AMQP traffic. You can disable
  # the AMQP protocol by commenting out the list of ports.
  ports: [5672]

.....
.....

# 181行目 : Kibana を使用する場合はコメント解除して出力先を指定
# Kibana で SSL 有効の場合は証明書に登録したホスト名と合わせる
# [username], [password] は管理ユーザーのユーザー名とパスワード
# 自己署名の証明書を使用している場合は [ssl.verification_mode: none]

setup.kibana:
.....
  host: "https://dlp.srv.world:5601"
  protocol: "https"
  username: "elastic"
  password: "password"
  ssl.enabled: true
  ssl.verification_mode: none

# 217行目 : Elasticsearch の出力先を指定する
# [username], [password] は管理ユーザーのユーザー名とパスワード
# [ssl.certificate_authorities] は Elasticsearch で生成された cacert

output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["https://dlp.srv.world:9200"]

  protocol: "https"
  username: "elastic"
  password: "password"
  ssl.certificate_authorities: "/etc/elasticsearch/certs/http_ca.crt"

.....
.....

[root@dlp ~]#
vi /etc/packetbeat/packetbeat.reference.yml
# 1870行目 : Kibana を使用する場合はコメント解除して出力先を指定
# Kibana で SSL 有効の場合は ssl 系設定をコメント解除
# [username], [password] は管理ユーザーのユーザー名とパスワード
# 自己署名の証明書を使用している場合は [ssl.verification_mode: none]

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: "https://dlp.srv.world:5601"

  # Optional protocol and basic auth credentials.
  protocol: "https"
  username: "elastic"
  password: "password"

  # Optional HTTP Path
  #path: ""

  # Use SSL settings for HTTPS. Default is true.
  ssl.enabled: true

.....
.....

  # after very careful consideration. It is primarily intended as a temporary
  # diagnostic mechanism when attempting to resolve TLS errors; its use in
  # production environments is strongly discouraged.
  # The default value is full.
  ssl.verification_mode: none

[root@dlp ~]#
systemctl enable --now packetbeat
[3] データが取り込まれているか確認しておきます。
# index 一覧

[root@dlp ~]#
curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt https://127.0.0.1:9200/_cat/indices?v

Enter host password for user 'elastic'
health status index                                                              uuid                   pri rep docs.count docs.deleted store.size pri.store.size dataset.size
.....
.....
yellow open   .ds-metricbeat-9.1.0-2025.08.06-000001                             0TnJalxZRTC3529MN3X87g   1   1         28            0    107.4kb        107.4kb      107.4kb
yellow open   .ds-packetbeat-9.1.1-2025.08.08-000001                             ca3CMl83RXGiJGodnrdrBQ   1   1          9            0     46.2kb         46.2kb       46.2kb

# index のドキュメント一覧

[root@dlp ~]#
curl -u elastic --cacert /etc/elasticsearch/certs/http_ca.crt https://127.0.0.1:9200/.ds-packetbeat-9.1.1-2025.08.08-000001/_search?pretty

Enter host password for user 'elastic':
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 207,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : ".ds-packetbeat-9.1.1-2025.08.08-000001",
        "_id" : "gwEEh5gBzSdMfqv7pvAV",
        "_score" : 1.0,
        "_source" : {
          "server" : {
            "port" : 53,
            "bytes" : 81,
            "ip" : "10.0.0.10"
          },
          "agent" : {
            "name" : "dlp.srv.world",
            "id" : "b45a0ec3-8ddb-450f-944d-b3940b276c3b",
            "type" : "packetbeat",
            "ephemeral_id" : "6c25bbac-9051-4ee8-b296-d881c9079a0e",
            "version" : "9.1.1"
          },
          "method" : "QUERY",
          "resource" : "dlp.srv.world",
          "query" : "class IN, type A, dlp.srv.world",
          "destination" : {
            "port" : 53,
            "bytes" : 81,
            "ip" : "10.0.0.10"
          },
          "dns" : {
            "op_code" : "QUERY",
            "resolved_ip" : [
              "10.0.0.30"
            ],
.....
.....
[4] Kibana を稼働させている場合は、サンプルダッシュボードへのデータインポートが可能です。
[root@dlp ~]#
packetbeat setup --dashboards

Loading dashboards (Kibana must be running and reachable)
Loaded dashboards
関連コンテンツ