Sign inSign up

instantlinux/dhcpd-dns-pxe

By instantlinux

Updated about 16 hours ago

Serve DNS, DHCP and TFTP from a small Alpine Linux container. This supplies ISC kea and dnsmasq.

Helm
Image
8

10K+

instantlinux/dhcpd-dns-pxe repository overview

dhcpd-dns-pxe

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.

Usage

In docker-compose.yml or helm, set the environment variables for your environment.

Mount these under /etc:

  • /etc/kea.d/local/reserve-.conf: Add any hardware MAC addresses for which you want static IP assignments (see dhcpd man page)
  • /etc/dnsmasq.d/local/hosts: Add entries you want added dnsmasq's DNS service (see syntax)

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@%:

CREATE DATABASE kea;
GRANT USAGE ON *.* TO `kea`@`%` IDENTIFIED BY '<password>';
GRANT ALL PRIVILEGES ON `kea`.* TO `kea`@`%`;

If you're using Swarm, see the docker-compose.yml file provided here in the source directory. This repo has complete instructions for building a kubernetes cluster where you can launch with helm, or kubernetes.yaml using make and customizing Makefile.vars after cloning this repo:

git clone https://github.com/instantlinux/docker-tools.git
cd docker-tools/k8s
make dhcpd-dns-pxe

This builds a failsafe cluster of DHCP servers under kubernetes using the helm chart. 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.

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 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.

I don't use the DHCP feature of dnsmasq; its software configuration is hugely different from ISC/kea and much more difficult to customize if you've been using ISC all along. If you've been using dnsmasq all along, simply set variable DHCP_ENABLE=no and volume-mount your configuration as /etc/dnsmasq.d/local/dhcpd-options.conf; dnsmasq will serve DHCP on port 67 if you have any such options specified.

Variables

These variables can be passed to the image from kubernetes.yaml or docker-compose.yml as needed:

VariableDefaultDescription
DB_HOSTdb00database host for kea
DB_INITIALIZEyesset to no after initial setup
DB_NAMEkeadb schema
DB_SECRETNAMEkea-db-passwordname of k8s secret
DB_USERkeadb username
DHCP_BOOTpxelinux.0PXE-boot filename
DHCP_ENABLEyesenable dhcp server
DHCP_LEASE_PATH/var/lib/miscdon't change this
DHCP_LEASE_TIME3600default lease time
DHCP_NETBIOS_NAME_SERVERSnetBIOS name servers
DHCP_SUBNET1192.168.1.0/24subnet
DHCP_SUBNET1_POOLdynamic IP pool, e.g. "192.168.1.101 - 192.168.1.150"
DNS_ENABLEyesenable dns server
DNS_SERVERlist of (other) DNS servers to send dhcp clients
DNS_UPSTREAM8.8.8.8upstream DNS server for queries (e.g. your ISP)
DOMAINexample.comyour domain name
IP_FORWARDINGfalseenable clients' IP forwarding
LISTEN_ADDRESSbind dnsmasq to IP address
MAX_LEASE_TIME14400maximum lease time
NTP_SERVER0.pool.ntp.org,1.pool.ntp.org
PORT_DNSMASQ_DNS53port number for DNS
SUBNET1_GATEWAY192.168.1.1gateway IP to send dhcp clients
SUBNET1_INTERFACEeth0serve only on this subnet
SUBNET1_NETMASK255.255.255.0network mask
TFTP_ENABLEyesenable tftp server
TFTP_ROOT/tftpboot/pxelinuxdon't change this
Secrets
SecretDescription
kea-db-passworddatabase password
Contributing

If you want to make improvements to this image, see CONTRIBUTING.

Tag summary

Content type

Image

Digest

sha256:adc537b81

Size

21 MB

Last updated

21 days ago

docker pull instantlinux/dhcpd-dns-pxe