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?

KeaDHCPとFRR+debian13ルータDHCPリレーエージェントを試す

0
Last updated at Posted at 2026-10-12

DHCPリレーの仕組み

インストール

環境

Proxmox

Ubuntu24LTS LXC非特権 Kea DHCP

hostname : dev-dhcp
eth0/20.0.0.2 L2SW2 待ち受けIP

Debian13 LXC特権 FRRuting

hostname dev-r1
eth0/20.0.0.1 L2SW2
eth1/10.0.0.1 L2SW1 DHCPリレー待ち受け

クライアント ubuntu24LTS LXC非特権

hostname dev-client
eth0/dhcp L2SW2

構築コマンドの例

dev-r1

dnsmasqを DHCPリレーエージェントとして使う。
isc-dhcp-relayはEOLのため使わない。

sudo apt update -y
sudo apt install -y dnsmasq
sudo nano /etc/dnsmasq.conf
#---
# DHCPリレー
# dhcp-relay=待ち受けIP,DHCP_IP
dhcp-relay=10.0.0.1,20.0.0.2
#---

sudo systemctl restart dnsmasq.service

設定を確認してみる

sudo systemctl status dnsmasq.service
#---結果
* dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
     Loaded: loaded (/usr/lib/systemd/system/dnsmasq.service; enabled; preset: enabled)
     Active: active (running) since Mon 2026-10-12 05:25:25 UTC; 3s ago
 Invocation: 473b6cc6ae244841bc642084a49f15a6
       Docs: man:dnsmasq(8)
    Process: 602 ExecStartPre=/usr/share/dnsmasq/systemd-helper checkconfig (code=exited, status=0/SUCCESS)
    Process: 608 ExecStart=/usr/share/dnsmasq/systemd-helper exec (code=exited, status=0/SUCCESS)
    Process: 615 ExecStartPost=/usr/share/dnsmasq/systemd-helper start-resolvconf (code=exited, status=0/SUCCESS)
   Main PID: 613 (dnsmasq)
      Tasks: 1 (limit: 215654)
     Memory: 684K (peak: 2.6M)
        CPU: 35ms
     CGroup: /system.slice/dnsmasq.service
             `-613 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local->

Oct 12 05:25:25 dev-r1 systemd[1]: Starting dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server...
Oct 12 05:25:25 dev-r1 dnsmasq[613]: started, version 2.91 cachesize 150
Oct 12 05:25:25 dev-r1 dnsmasq[613]: DNS service limited to local subnets
Oct 12 05:25:25 dev-r1 dnsmasq[613]: compile time options: IPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack i>
Oct 12 05:25:25 dev-r1 dnsmasq-dhcp[613]: DHCP relay from 10.0.0.1 to 20.0.0.2
Oct 12 05:25:25 dev-r1 dnsmasq[613]: reading /etc/resolv.conf
Oct 12 05:25:25 dev-r1 dnsmasq[613]: using nameserver 106.187.2.33#53
Oct 12 05:25:25 dev-r1 dnsmasq[613]: using nameserver 106.187.2.41#53
Oct 12 05:25:25 dev-r1 dnsmasq[613]: read /etc/hosts - 8 names
Oct 12 05:25:25 dev-r1 systemd[1]: Started dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server.
#---
#DHCP relay from 10.0.0.1 to 20.0.0.2
#を確認できた。

設定ファイル

# Kea-DHCP4の設定ファイル
sudo nano /etc/kea/kea-dhcp4.conf
#---
{
    "Dhcp4": {
        "interfaces-config": {
            "interfaces": ["eth0"]
        },
        "control-socket": {
            "socket-type": "unix",
            "socket-name": "/run/kea/kea4-ctrl-socket"
        },
        "lease-database": {
            "type": "memfile",
            "lfc-interval": 3600
        },
        "valid-lifetime": 600,
        "max-valid-lifetime": 7200,
        "subnet4": [{
            "id": 1,
            "subnet": "10.0.0.0/24",
            "pools": [{
                "pool": "10.0.0.100 - 10.0.0.200"
            }],
            "option-data": [{
                    "name": "routers",
                    "data": "10.0.0.1"
                },
                {
                    "name": "domain-name-servers",
                    "data": "8.8.8.8"
                },
                {
                    "name": "domain-name",
                    "data": "dev.home.arpa"
                }
            ]
        }]
    }
}

sudo bash -c '
kea-shell \
  --host 127.0.0.1 \
  --port 8000 \
  --auth-user kea-api \
  --auth-password "$(cat /etc/kea/kea-api-password)" \
  --service dhcp4 config-reload
'

クライアントのコンソールから結果を確認する

# 現在のDHCPによって割り当てられたIPを返却する
sudo dhclient -r

# IPをDHCPから取得する
sudo dhclient -v

取得できている

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: eth0@if252: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether bc:24:11:6e:05:45 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.0.0.100/24 metric 1024 brd 10.0.0.255 scope global dynamic eth0
       valid_lft 573sec preferred_lft 573sec
    inet6 fe80::be24:11ff:fe6e:545/64 scope link 
       valid_lft forever preferred_lft forever
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?