You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serve DNS and DHCP from one or more small Alpine Linux container(s). This
5
-
supplies DNS and tftp (for network PXE booting) using dnsmasq, and
6
-
DHCP using your choice of the original ISC dhcpd or the newer
7
-
dnsmasq. Any of the three services can be enabled or disabled.
4
+
Serve DNS and DHCP from one or more small Alpine Linux container(s). This supplies DNS and tftp (for network PXE booting) using dnsmasq, and DHCP using your choice of kea or dnsmasq. Any of the three services can be enabled or disabled. ISC dhcpd is deprecated by its maintainers, and replaced here with kea in January 2026 starting with tag `3.0.2-r0-2.91-r0`. Look at the subnet and reservation definitions for breaking changes.
8
5
9
6
### Usage
10
7
11
8
In kubernetes.yaml / docker-compose.yml, set the environment variables for your environment.
12
9
13
10
Mount these under /etc:
14
11
15
-
* /etc/dhcpd.d/local/reserve-<net>.conf: Add any hardware MAC addresses for which you want static IP assignments (see [dhcpd man page](https://linux.die.net/man/5/dhcpd.conf))
16
-
* /etc/dhcpd.d/local/ranges: Optional non-overlapping range definitions as noted below
12
+
* /etc/kea.d/local/reserve-<net>.conf: Add any hardware MAC addresses for which you want static IP assignments (see [dhcpd man page](https://linux.die.net/man/5/dhcpd.conf))
17
13
* /etc/dnsmasq.d/local/hosts: Add entries you want added dnsmasq's DNS service (see [syntax](https://linux.die.net/man/5/hosts))
18
14
19
-
Mount your PXE boot images and client definitions under /tftpboot/pxelinux.
15
+
Mount your PXE boot images and client definitions under /tftpboot/pxelinux. Kea stores reservations on a mariadb/mysql database: generate a secret for database access, and create an empty database `kea` with a user `kea`@`%`:
16
+
```
17
+
CREATE DATABASE kea;
18
+
GRANT USAGE ON *.* TO `kea`@`%` IDENTIFIED BY '<password>';
19
+
GRANT ALL PRIVILEGES ON `kea`.* TO `kea`@`%`;
20
+
```
20
21
21
-
See the kubernetes.yaml provided here. If you're using Swarm, see the docker-compose.yml file provided here in the source directory; this needs to run on host network with kernel capability CAP_NET_ADMIN, so it will not currently run in Docker Swarm. (You can run a single instance of this via _docker run_ or _docker-compose_.) This repo has complete instructions for
22
+
See the kubernetes.yaml provided here. If you're using Swarm, see the docker-compose.yml file provided here in the source directory. This repo has complete instructions for
22
23
[building a kubernetes cluster](https://github.com/instantlinux/docker-tools/blob/main/k8s/README.md) where you can launch with [helm](https://github.com/instantlinux/docker-tools/tree/main/images/dhcpd-dns-pxe/helm), or [kubernetes.yaml](https://github.com/instantlinux/docker-tools/blob/main/images/dhcpd-dns-pxe/kubernetes.yaml) using _make_ and customizing [Makefile.vars](https://github.com/instantlinux/docker-tools/blob/main/k8s/Makefile.vars) after cloning this repo:
You can build a failsafe cluster of DHCP servers under kubernetes using the kubernetes.yaml definition here. Define a ConfigMap with non-overlapping range definitions such as "192.168.1.32 192.168.1.63", "192.16.1.64 192.168.1.95", "192.168.1.96 192.168.1.127" for a set of 3 replicas. If a replica goes down, the others will continue to assign addresses. They won't conflict thanks to the way DHCP protocol works; a client will use the first address offered and ignore any additional offers from the server pool. If a blank range is specified, the dhcp server will offer only reserved MAC/IP assignments.
30
+
You can build a failsafe cluster of DHCP servers under kubernetes using the helm chart included here. Define a ConfigMap with your reservations defined as shown in kea documentation, and hosts defined as in the dnsmasq documentation. If a replica goes down, the others will continue to assign addresses. They won't conflict thanks to the way DHCP protocol works; a client will use the first address offered and ignore any additional offers from the server pool. Subsequent requests will be checked against the reservations database.
30
31
31
32
Verified to work with a single subnet and with the limited set of DHCP/DNS options supported in environment vars defined here. Additional options as defined in the [dnsmasq man page](https://linux.die.net/man/8/dnsmasq) can be specified as any .conf file under /etc/dnsmasq.d/local volume mount, and for dhcpd as any .conf file under /etc/dhcpd.d/local.
32
33
33
34
I don't use the DHCP feature of dnsmasq; its software configuration
34
-
is hugely different from ISC and much more difficult to customize if
35
+
is hugely different from ISC/kea and much more difficult to customize if
35
36
you've been using ISC all along. If you've been using dnsmasq all
36
37
along, simply set variable DHCP_ENABLE=no and volume-mount your configuration as /etc/dnsmasq.d/local/dhcpd-options.conf; dnsmasq will serve
37
38
DHCP on port 67 if you have any such options specified.
@@ -42,18 +43,24 @@ These variables can be passed to the image from kubernetes.yaml or docker-compos
42
43
43
44
Variable | Default | Description |
44
45
-------- | ------- | ----------- |
46
+
DB_HOST | db00 | database host for kea
47
+
DB_INITIALIZE | yes | set to no after initial setup
48
+
DB_NAME | kea | db schema
49
+
DB_SECRETNAME | kea-db-password | name of k8s secret
50
+
DB_USER | kea | db username
45
51
DHCP_BOOT | pxelinux.0 | PXE-boot filename
46
52
DHCP_ENABLE | yes | enable dhcp server
47
53
DHCP_LEASE_PATH | /var/lib/misc | don't change this
48
54
DHCP_LEASE_TIME | 3600 | default lease time
49
55
DHCP_NETBIOS_NAME_SERVERS | | netBIOS name servers
50
-
DHCP_RANGE | | dynamic IP pool, e.g. "192.168.1.101 192.168.1.150"
56
+
DHCP_SUBNET1 | 192.168.1.0/24 | subnet
57
+
DHCP_SUBNET1_POOL | | dynamic IP pool, e.g. "192.168.1.101 - 192.168.1.150"
51
58
DNS_ENABLE | yes | enable dns server
52
59
DNS_SERVER | | list of (other) DNS servers to send dhcp clients
53
60
DNS_UPSTREAM | 8.8.8.8 | upstream DNS server for queries (e.g. your ISP)
54
61
DOMAIN | example.com | your domain name
55
62
IP_FORWARDING | false | enable clients' IP forwarding
0 commit comments