rss logo

Setting Up and Configuring a DHCP Server on OpenBSD

OpenBSD Logo

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.

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;
}