Setting Up and Configuring a DHCP Server on OpenBSD
- Last updated: Jun 20, 2025
This guide demonstrates how to use the robust and secure OpenBSD operating system to set up a DHCP server.
I recently needed to configure a DHCP server for a Wi-Fi guest network, and OpenBSD proved to be the ideal solution: lightweight, highly secure, and remarkably stable.
- DHCP Configuration Parameters:
- Network: 192.168.1.0/24
- Gateway: 192.168.1.254
- DHCP range: 192.168.1.20 to 192.168.1.200
- DNS: 8.8.8.8 and 192.168.1.1
- domain: wifiguest.std.rocks
Configuration
Note: A sample configuration file is available at /etc/examples/dhcpd.conf for reference.
- Edit or create the main configuration file at
/etc/dhcpd.conf
:
# $OpenBSD: dhcpd.conf,v 1.1 2014/07/11 21:20:10 deraadt Exp $
#
# DHCP server options.
# See dhcpd.conf(5) and dhcpd(8) for more information.
#
option domain-name "wifiguest.std.rocks";
option domain-name-servers 8.8.8.8, 192.168.1.1;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.254;
range 192.168.1.20 192.168.1.200;
#if needed to specify static address
#host static-client {
# hardware ethernet 11:11:11:aa:aa:aa;
# fixed-address 192.168.1.30;
#}
}
Enable and Start the dhcpd Service
- To enable the
dhcpd
service at boot time:
OpenBSD# rcctl enable dhcpd
- To start the service immediately:
OpenBSD# rcctl start dhcpd
- To verify that the service is running:
OpenBSD# rcctl check dhcpd
View DHCP Leases
- Display the list of active DHCP leases:
OpenBSD# cat /var/db/dhcpd.leases
lease 192.168.1.20 {
starts 3 2023/11/01 14:15:24 UTC;
ends 4 2023/11/02 02:15:24 UTC;
hardware ethernet 63:a0:03:59:23:b3;
uid 01:63:a0:03:59:23:b3;
}