【RHEL9】Kea DHCPを最小構成で立ち上げる

【RHEL9】Kea DHCPを最小構成で立ち上げる

小規模セグメントに、Kea DHCPv4 で「192.168.12.10 から 192.168.12.200 の範囲だけ」IP を払い出す最小構成を、RHEL 9で作成する。
初期セットアップ、設定ファイル、起動・確認までをまとめる。

Kea DHCPとは?

Kea DHCPは、Internet Systems Consortium(ISC)が開発する次世代のオープンソースDHCPサーバで、DHCPv4とDHCPv6の両方をサポートする。
設定はJSON形式で扱え、Control AgentのREST APIで動的制御できるほか、リースはmemfileに加えてMySQL/PostgreSQLへ保存できる。
旧来のISC DHCPは2022年にEOLとなり、Keaへの移行が公式に推奨されている。(isc.org)

想定イメージ

flowchart LR
  subgraph LAN["192.168.12.0/24"]
    GW["Router
192.168.12.1"] Srv["Kea DHCPv4
RHEL 9.5
192.168.12.11"] C1["Client A"] C2["Client B"] end Srv -->|assigns| C1 Srv -->|assigns| C2 C1 --> GW C2 --> GW

EPEL を有効化する

Kea DHCPインストールにEPELが必要なため、有効化を行う
CodeReady Builder を有効化(RHELはsubscription-manager)
# subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms

[root@localhost dhclient.d]# subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms
リポジトリー 'codeready-builder-for-rhel-9-x86_64-rpms' は、このシステムに対して有効になりました。

EPELリポジトリを追加

# dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm

[root@localhost dhclient.d]# dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
サブスクリプション管理リポジトリーを更新しています。
Red Hat CodeReady Linux Builder for RHEL 9 x86_64 (RPMs)                                                                17 MB/s |  13 MB     00:00
メタデータの期限切れの最終確認: 0:00:01 前の 2025年08月31日 22時14分06秒 に実施しました。
epel-release-latest-9.noarch.rpm                                                                                        25 kB/s |  19 kB     00:00
依存関係が解決しました。
=======================================================================================================================================================
 パッケージ                            アーキテクチャー                バージョン                          リポジトリー                          サイズ
=======================================================================================================================================================
インストール:
 epel-release                          noarch                          9-10.el9                            @commandline                           19 k

トランザクションの概要
=======================================================================================================================================================
インストール  1 パッケージ

合計サイズ: 19 k
インストール後のサイズ: 26 k
パッケージのダウンロード:
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
  準備中           :                                                                                                                               1/1
  インストール中   : epel-release-9-10.el9.noarch                                                                                                  1/1
  scriptletの実行中: epel-release-9-10.el9.noarch                                                                                                  1/1
Many EPEL packages require the CodeReady Builder (CRB) repository.
It is recommended that you run /usr/bin/crb enable to enable the CRB repository.

  検証中           : epel-release-9-10.el9.noarch                                                                                                  1/1
インストール済みの製品が更新されています。

インストール済み:
  epel-release-9-10.el9.noarch

完了しました!

メタデータ更新

# dnf makecache

[root@localhost dhclient.d]# dnf makecache
サブスクリプション管理リポジトリーを更新しています。
Extra Packages for Enterprise Linux 9 - x86_64                                                                          12 MB/s |  20 MB     00:01
Extra Packages for Enterprise Linux 9 openh264 (From Cisco) - x86_64                                                   1.3 kB/s | 2.5 kB     00:01
Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)                                                                   30 kB/s | 4.1 kB     00:00
Red Hat CodeReady Linux Builder for RHEL 9 x86_64 (RPMs)                                                                33 kB/s | 4.5 kB     00:00
Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)                                                                30 kB/s | 4.5 kB     00:00
メタデータキャッシュを作成しました。

Kea DHCPをインストール

# dnf install -y kea

インストールを確認

# dnf list --installed | grep kea

[root@localhost dhclient.d]# dnf list --installed | grep kea
kea.x86_64                                    2.6.3-1.el9                   @epel
kea-libs.x86_64                               2.6.3-1.el9                   @epel

DHCPを出すインターフェース名を特定。(例: ens192)。対象セグメントのIPを手がかりに拾う
# ip -o -4 addr show | awk '/192.168.12./{print $2; exit}'

[root@localhost dhclient.d]# ip -o -4 addr show | awk '/192\.168\.12\./{print $2; exit}'
ens18

設定ファイルをバックアップ
# cp -p /etc/kea/kea-dhcp4.conf /etc/kea/kea-dhcp4.conf.bak

設定ファイルを編集
# vi /etc/kea/kea-dhcp4.conf

[root@localhost dhclient.d]# vi /etc/kea/kea-dhcp4.conf
{
  "Dhcp4": {
    "interfaces-config": {
      "interfaces": [ "ens18" ]
    },

    "control-socket": {
      "socket-type": "unix",
      "socket-name": "kea4-ctrl-socket"
    },

    "lease-database": {
      "type": "memfile",
      "lfc-interval": 3600
    },

    "expired-leases-processing": {
      "reclaim-timer-wait-time": 10,
      "flush-reclaimed-timer-wait-time": 25,
      "hold-reclaimed-time": 3600,
      "max-reclaim-leases": 100,
      "max-reclaim-time": 250,
      "unwarned-reclaim-cycles": 5
    },

    "renew-timer": 900,
    "rebind-timer": 1800,
    "valid-lifetime": 3600,

    "option-data": [
      { "name": "domain-name-servers", "data": "8.8.8.8, 1.1.1.1" },
      { "name": "domain-name",         "data": "example.local" }
    ],

    "subnet4": [
      {
        "id": 1,
        "subnet": "192.168.12.0/24",
        "pools": [ { "pool": "192.168.12.10 - 192.168.12.200" } ],
        "option-data": [
          { "name": "routers", "data": "192.168.12.1" }
        ]
      }
    ],

    "loggers": [
      {
        "name": "kea-dhcp4",
        "output-options": [ { "output": "kea-dhcp4.log" } ],
        "severity": "INFO",
        "debuglevel": 0
      }
    ]
  }
}

重要: 上記のens18設定に合わせたNIC名に置き換えること。

firewalld(UDP/67)を開放する
# firewall-cmd --add-port=67/udp --permanent
# firewall-cmd --reload

構文チェック & 起動
# kea-dhcp4 -t /etc/kea/kea-dhcp4.conf
# systemctl enable --now kea-dhcp4

クライアント側での確認(Windows)
ipconfig /all

PS C:\Users\Administrator> ipconfig /all

Windows IP 構成

イーサネット アダプター イーサネット 2:

   接続固有の DNS サフィックス . . . . .: example.local
   説明. . . . . . . . . . . . . . . . .: Intel(R) PRO/1000 MT Network Connection #2
   物理アドレス. . . . . . . . . . . . .: BC-24-11-98-0F-60
   DHCP 有効 . . . . . . . . . . . . . .: はい
   自動構成有効. . . . . . . . . . . . .: はい
   リンクローカル IPv6 アドレス. . . . .: fe80::ede1:4bf6:c0b9:9149%7(優先)
   IPv4 アドレス . . . . . . . . . . . .: 192.168.12.12(優先)
   サブネット マスク . . . . . . . . . .: 255.255.255.0
   リース取得. . . . . . . . . . . . . .: 2025年8月31日 22:29:51
   リースの有効期限. . . . . . . . . . .: 2025年8月31日 23:59:51
   デフォルト ゲートウェイ . . . . . . .: 192.168.12.1
   DHCP サーバー . . . . . . . . . . . .: 192.168.12.11
   DHCPv6 IAID . . . . . . . . . . . . .: 347874321
   DHCPv6 クライアント DUID. . . . . . .: 00-01-00-01-2F-37-BE-90-BC-24-11-35-72-C6
   DNS サーバー. . . . . . . . . . . . .: 8.8.8.8
   NetBIOS over TCP/IP . . . . . . . . .: 有効

まとめ

  • Kea DHCPv4 は 最小設定でも十分実用的
  • まずは インターフェース名・サブネット・プール・ゲートウェイ の4点を正しく入れる。
  • 設定反映は systemd 再起動のほか、コントロールソケット経由で config-reload も可能(運用自動化に便利)。

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *