0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

kea DHCPサービスエラー。構文はあってるのに

0
Posted at

systemctl 経由でkeaサービスがエラーになる原因をデバックする

環境

Ubuntu24LTS LXC PVE

サービス名を確認

systemctl list-units --type=service | grep kea
#---
  kea-dhcp-ddns-server.service                loaded active running Kea DDNS Service
* kea-dhcp4-server.service                    loaded failed failed  Kea IPv4 DHCP daemon
  kea-dhcp6-server.service                    loaded active running Kea IPv6 DHCP daemon

ステータスを確認

root@id2000-kea-dhcp-1:~# sudo systemctl status kea-dhcp4-server.service
x kea-dhcp4-server.service - Kea IPv4 DHCP daemon
     Loaded: loaded (/usr/lib/systemd/system/kea-dhcp4-server.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Mon 2026-10-12 12:41:45 UTC; 2s ago
   Duration: 48ms
 Invocation: eee81cff49e345398bca85bb667f91e7
       Docs: man:kea-dhcp4(8)
    Process: 3227 ExecStart=/usr/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf (code=exited, status=1/FAILURE)
   Main PID: 3227 (code=exited, status=1/FAILURE)
   Mem peak: 2.8M
        CPU: 27ms

Oct 12 12:41:45 id2000-kea-dhcp-1 systemd[1]: Started kea-dhcp4-server.service - Kea IPv4 DHCP daemon.
Oct 12 12:41:45 id2000-kea-dhcp-1 systemd[1]: kea-dhcp4-server.service: Main process exited, code=exited, status=1/FAILURE
Oct 12 12:41:45 id2000-kea-dhcp-1 kea-dhcp4[3227]: 2026-10-12 12:41:45.468 INFO  [kea-dhcp4.dhcp4/3227.126849752647616] DHCP4_STARTING Kea DHCPv4 server version 2.6.3 (stable) starting
Oct 12 12:41:45 id2000-kea-dhcp-1 kea-dhcp4[3227]: 2026-10-12 12:41:45.468 ERROR [kea-dhcp4.dhcp4/3227.126849752647616] DHCP4_CONFIG_LOAD_FAIL configuration error using file: /etc/kea/kea>
Oct 12 12:41:45 id2000-kea-dhcp-1 kea-dhcp4[3227]: 2026-10-12 12:41:45.468 ERROR [kea-dhcp4.dhcp4/3227.126849752647616] DHCP4_INIT_FAIL failed to initialize Kea server: configuration erro>
Oct 12 12:41:45 id2000-kea-dhcp-1 systemd[1]: kea-dhcp4-server.service: Failed with result 'exit-code'.

設定ファイル読み込みに失敗したため初期化が失敗している
DHCP4_CONFIG_LOAD_FAIL

構文エラーをまず疑った。
以下のコマンドで確認できる

sudo kea-dhcp4 -t /etc/kea/kea-dhcp4.conf

結果

INFO  [kea-dhcp4.hosts/3255.138365610854336] HOSTS_BACKENDS_REGISTERED the following host backend types are available: mysql postgresql 
WARN  [kea-dhcp4.dhcpsrv/3255.138365610854336] DHCPSRV_MT_DISABLED_QUEUE_CONTROL disabling dhcp queue control when multi-threading is enabled.
WARN  [kea-dhcp4.dhcp4/3255.138365610854336] DHCP4_RESERVATIONS_LOOKUP_FIRST_ENABLED Multi-threading is enabled and host reservations lookup is always performed first.
INFO  [kea-dhcp4.dhcpsrv/3255.138365610854336] DHCPSRV_CFGMGR_NEW_SUBNET4 a new subnet has been added to configuration: 192.168.200.160/27 with params: valid-lifetime=600
INFO  [kea-dhcp4.dhcpsrv/3255.138365610854336] DHCPSRV_CFGMGR_SOCKET_TYPE_SELECT using socket type raw
INFO  [kea-dhcp4.dhcpsrv/3255.138365610854336] DHCPSRV_CFGMGR_ADD_IFACE listening on interface eth0
INFO  [kea-dhcp4.dhcpsrv/3255.138365610854336] DHCPSRV_CFGMGR_SOCKET_TYPE_DEFAULT "dhcp-socket-type" not specified , using default socket type raw

警告がふたつ。エラーの原因は構文ではないよう

DHCPSRV_MT_DISABLED_QUEUE_CONTROL disabling dhcp queue control when multi-threading is enabled.
DHCP4_RESERVATIONS_LOOKUP_FIRST_ENABLED Multi-threading is enabled and host reservations lookup is always performed first.

手動でサービスをスタートさせ、ログに出す

sudo systemctl stop kea-dhcp4-server
sudo /usr/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf

ログを下にペーストしてみた
WARNと一部のINFO,ERRORはなかった。

#略...
DHCP4_PACKET_SEND [hwtype=1 bc:24:11:ea:85:34], cid=[no info], tid=0x6a600c6b: trying to send packet DHCPOFFER (type 2) from 192.168.200.130:67 to 192.168.200.161:67 on interface eth0
DHCP4_PACKET_RECEIVED [hwtype=1 bc:24:11:ea:85:34], cid=[no info], tid=0x6a600c6b: DHCPREQUEST (type 3) received from 192.168.200.161 to 192.168.200.130 on interface eth0
DHCP4_LEASE_ALLOC [hwtype=1 bc:24:11:ea:85:34], cid=[no info], tid=0x6a600c6b: lease 192.168.200.170 has been allocated for 600 seconds
DHCP4_PACKET_SEND [hwtype=1 bc:24:11:ea:85:34], cid=[no info], tid=0x6a600c6b: trying to send packet DHCPACK (type 5) from 192.168.200.130:67 to 192.168.200.161:67 on interface eth0
DHCP4_SHUTDOWN server shutdown

手動の起動では正常にクライアントにIPが配られるのに
systemctl 経由だとエラーになる。

メッセージの意味はここから知ることができる

情報源

chatGPTを便りにおすすめのサイトを挙げてもらった

image.png

原因探し

sudo systemctl edit kea-dhcp4-server
#---
#以下の項目を次のように変更
[Service]
#User=_kea #コメントアウト
User=root
Group=root
StandardOutput=journal+console
StandardError=journal+console
#---

再起動

sudo systemctl restart kea-dhcp4-server

ステータス確認
エラーないね、、keaユーザが関係してそう

sudo systemctl status kea-dhcp4-server
#---結果
* kea-dhcp4-server.service - Kea IPv4 DHCP daemon
     Loaded: loaded (/usr/lib/systemd/system/kea-dhcp4-server.service; enabled; preset: enabled)
    Drop-In: /etc/systemd/system/kea-dhcp4-server.service.d
             `-override.conf
     Active: active (running) since Mon 2026-10-12 13:10:54 UTC; 9s ago
 Invocation: ecf415ce0e6c4656bd6051de01ece141
       Docs: man:kea-dhcp4(8)
   Main PID: 3334 (kea-dhcp4)
      Tasks: 6 (limit: 215654)
     Memory: 2.7M (peak: 3M)
        CPU: 32ms
     CGroup: /system.slice/kea-dhcp4-server.service
             `-3334 /usr/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf

Oct 12 13:10:54 id2000-kea-dhcp-1 kea-dhcp4[3334]: 2026-10-12 13:10:54.497 INFO  [kea-dhcp4.dhcpsrv/3334.134550977193920] DHCPSR>
Oct 12 13:10:54 id2000-kea-dhcp-1 kea-dhcp4[3334]: 2026-10-12 13:10:54.498 INFO  [kea-dhcp4.commands/3334.134550977193920] COMMA>

仮説

原因は設定ファイルの権限だと予想した。
rootユーザではエラーなく、
_keaユーザ(デフォルトのコメントアウトされていたユーザ名)
だとファイルにアクセスできなかったため、
設定ファイルを読み込めず初期化失敗となっていたのではないか
手動で起動できたのもroot権限だったからでは。

そういえば

このkeaサーバ
ansibleでデプロイしていた。
rootユーザでファイルの設定をしていた記憶...

検証

_keaユーザで手動実行するとsystemctl 経由と同じエラーになるはず。
_keaユーザで手動起動してみる

sudo -u _kea /usr/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf
#---結果
Unable to use interprocess sync lockfile (Permission denied): /var/run/kea/logger_lockfile
kea-dhcp4: Fatal error during start up: Unable to open PID file '/run/kea/kea-dhcp4.kea-dhcp4.pid' for write
Unable to use interprocess sync lockfile (Permission denied): /var/run/kea/logger_lockfile

予想していたエラーになった。
ランタイムディレクトリへの_kea ユーザーの書き込み権限の欠如

/var/run/...

オーバライドを元に戻す

sudo systemctl edit kea-dhcp4-server

所有者を_keaにする。

sudo chown -R _kea:_kea /var/run/kea
sudo chown -R _kea:_kea /run/kea
sudo chown -R _kea: /etc/kea/kea-dhcp4.conf
sudo systemctl daemon-reload
sudo systemctl restart kea-dhcp4-server
sudo systemctl status kea-dhcp4-server --no-pager

結果

sudo systemctl restart kea-dhcp4-server
sudo systemctl status kea-dhcp4-server --no-pager
* kea-dhcp4-server.service - Kea IPv4 DHCP daemon
     Loaded: loaded (/usr/lib/systemd/system/kea-dhcp4-server.service; enabled; preset: enabled)
    Drop-In: /etc/systemd/system/kea-dhcp4-server.service.d
             `-override.conf
     Active: active (running) since Mon 2026-10-12 13:25:09 UTC; 50ms ago
 Invocation: 9de82c8c172f4a1aac499c42aac692ae
       Docs: man:kea-dhcp4(8)
   Main PID: 3482 (kea-dhcp4)
      Tasks: 1 (limit: 215654)
     Memory: 1.7M (peak: 1.7M)
        CPU: 6ms
     CGroup: /system.slice/kea-dhcp4-server.service
             `-3482 /usr/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf

Oct 12 13:25:09 id2000-kea-dhcp-1 systemd[1]: Started kea-dhcp4-server.service - ...mon.
Hint: Some lines were ellipsized, use -l to show in full.

結果

ステータスは正常になった。
クライアントからDHCPリクエストを送ってみる

sudo dhclient -v
#---
Internet Systems Consortium DHCP Client 4.4.3-P1
Copyright 2004-2022 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/bc:24:11:ea:85:34
Sending on   LPF/eth0/bc:24:11:ea:85:34
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
DHCPOFFER of 192.168.200.170 from 192.168.200.161
DHCPREQUEST for 192.168.200.170 on eth0 to 255.255.255.255 port 67
DHCPACK of 192.168.200.170 from 192.168.200.161
bound to 192.168.200.170 -- renewal in 255 seconds

正常に受け取れていることを確認

これから注意すること

設定ファイルなど、作成時の権限チェックを怠らない。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?