Dynamic Host Configuration Protocol #

The Dynamic Host Configuration Protocol (DHCP) is a way to configure network interfaces automatically. OpenBSD can be a DHCP server that configures other machines, or a DHCP client that is configured by a DHCP server.

DHCP Server #

First we need to create a valid configuration for the dhcp server. As usual with Base services, there’s an example file in /etc/examples/dhcpd.conf. Copy the example file to /etc cp /etc/examples/dhcpd.conf /etc/.

The example file looks like the following:

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

# Network:
# Domain name:		my.domain
# Name servers: and
# Default router:
# Addresses: -
option  domain-name "my.domain";
option  domain-name-servers,;

subnet netmask {
	option routers;


	host static-client {
		hardware ethernet 22:33:44:55:66:77;

	host pxe-client {
		hardware ethernet 02:03:04:05:06:07;
		filename "pxeboot";

This file assumes the ip address of the router, or gateway, to be Change it to the actual ip address of your router/gateway. Also, it assumes that the DNS servers on your local network to be found on and Change the ip addresses on the “option domain-name-servers,;” line to whatever name servers you wish to use. They can also be external ip addresses like Google’s and, or Cloudflare’s

It’s possible to use the DHCP server to assign the same ip address to the same MAC address everytime a DHCP request is being made. This can be useful for servers like a fileserver, ftp-server, or web server, on your local network. If you don’t plan on using this feature, it’s safe to remove the entries from the configuration file. If you would like to use the feature, look up the MAC address, or hardware address of the server/machine you wish to assign the “static” ip address to.

Once the configuration file contains the correct values, it’s time to start the server.

rcctl start dhcpd

In order to start the DHCP server next time the server is started, use the following command

rcctl enable dhcpd

By default, the OpenBSD DHCP server will listen on all network interfaces for DHCP requests. If you run the service on a router/gateway, it’s important to make sure it only listens on the local/internal network interface. Use the following command to make the DHCP service listen only on one interface. In this case the interface is re1. Use the ifconfig command to find out the interface name of your local network.

rcctl set dhcpd flags re1