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?

ubunntuにkeaDHCPとkeaKeeper入れる

0
Last updated at Posted at 2025-12-03

この記事はIPFactory Advent Calender 2025 4日目の記事です。

ubunntuにkeaDHCPとkeaKeeperをインストールする

proxmoxで自宅LANと隔離された空間を作ったら中にDHCPが欲しくなったから建てる。

公式のドキュメント見てね~

ちなkeaKeeperの動作環境がver2.4なのでaptで入れるとドキュメントにない設定が必要になりそう:)

mySqlの構築

どうやらリースしたipの保存にいくつか方法があるらしいのだが、今回はkeakeeperを利用してみたいと思っているのでmariaDBを導入する。

 apt install mariadb-server 

mariadbのInstalling MariaDB Server Guideの手順を踏む

 mariadb-secure-installation

kea / keaKeeper用のデータベースを作成する

DB> create databese kea;

上記用のユーザーを作成

DB> grant ALL ON kea.* TO kea@localhost identified by 'password';
DB> quit;

mariaDBの起動/有効化

systemctl start mariadb.service
systemctl enable mariadb.service

phpのインストール

keaKeeperがphp/apacheで動くのでインストールする

apt install apache2 php php-cli php-common php-mbstring php-pdo php-mysql php-curl

php.ini の設定をする(タイムゾーンの設定)

vim /etc/php/8.3/apache2/php.ini

[Date]
;date.timezone =
date.timezone = Asia/Tokyo

keaのインストール

apt install kea

keaに設定を入れる
今回はDHCPv4のみ

kea用のDBテーブルの作成

kea-admin db-init mysql -h localhost -u kea -p password -n kea

lease-databaseとhosts-databaseにDB情報を記述する

vim /etc/kea/kea-dhcp4.conf

編集箇所
hostをlocalhostにするとなんか動かなかった

~~~
"lease-database": {
    "type": "mysql",
    "host": "127.0.0.1",
    "name": "kea",
    "user": "kea",
    "password": "password",
    "port": 3306,
    "lfc-interval": 3600
},
~~~
"hosts-database": {
     "type": "mysql",
     "name": "kea",
     "user": "kea",
     "password": "password",
     "host": "127.0.0.1",
     "port": 3306
 },
 ~~~
 "subnet4": [
    {
        // This defines the whole subnet. Kea will use this information to
        // determine where the clients are connected. This is the whole
        // subnet in your network.

        // Subnet identifier should be unique for each subnet.
        "id": 1,

        // This is mandatory parameter for each subnet.
        "subnet": "192.168.170.0/24",

        // Pools define the actual part of your subnet that is governed
        // by Kea. Technically this is optional parameter, but it's
        // almost always needed for DHCP to do its job. If you omit it,
        // clients won't be able to get addresses, unless there are
        // host reservations defined for them.
        "pools": [ { "pool": "192.168.170.100 - 192.168.170.200" } ],

        // These are options that are subnet specific. In most cases,
        // you need to define at least routers option, as without this
        // option your clients will not be able to reach their default
        // gateway and will not have Internet connectivity.
        "option-data": [
            {
                // For each IPv4 subnet you most likely need to specify at
                // least one router.
                "name": "routers",
                "data": "192.168.170.10"
            }
        ],

"reservations": < こいつの中はコメントアウトする
やってることはipaddressの予約

kea-ctrl-agentのbasic認証を無効化する

#"authentication": {
#    "type": "basic",
#    "realm": "Kea Control Agent",
#    "directory": "/etc/kea",
#    "clients": [
#        {
#            "user": "kea-api",
#            "password-file": "kea-api-password"
#        }
#    ]
# },

keaKeeperのインストール

keaKeeperをインストールする
githubにリリースページがある
この記事時点では1.05が最新
githubページ

wget ダウンロードURL
tar -xf keakeeper-1.05.tar.gz -C /var/www/html

webサーバーからのアクセス権限をつける

chown -R www-data:www-data /var/www/html/keakeeper/

keaKeeperからkeaの設定ファイルに書き込みができるようにする

chown -R _kea:www-data /etc/kea/
chmod -R 755 /etc/kea/

keaKeeperに設定を入れる

vim /var/www/html/keakeeper/config/application.ini

以下の編集をする

[db]
driver = 'mysql'
host = 'localhost'
port = 3306
database = 'kea'
user = 'kea'
password = 'Password'

[path]
login[] = '/keakeeper/'
login[] = '/keakeeper/index.php'

[api]
server       = 'http://127.0.0.1:8000'

認証テーブルをDBに流し込む

mysql -u kea -p kea < /var/www/html/keakeeper/db/auth.sql

apacheエイリアスを設定する

vim /etc/apache2/sites-available/keakeeper.conf

内容

Alias /keakeeper /var/www/html/keakeeper/public
<Directory "/var/www/html/keakeeper/public">
    require all granted
</Directory>

サイトの有効化

a2ensite keakeeper

"http://ipaddress/keakeeper" でアクセスする

ログイン画面画像

初期のユーザー/パスワード

user admin
pass admin

動作確認

networkに接続してdhcpを配布させてみる

ubuntuのターミナル画像

上から順にipaddress/defaultRouteが配布されている
keakeeperからleaseされているipaddressを確認する

keakeeperのSearchLeaseの画像

でけちゃ:)

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?