Configuring DHCPd

DHCP can be a real convenience for your users, since DHCP provides the networking information for all machines on a physical network. This allows your users to skip manual networking configuration.

OpenBSD includes a DHCP server based on software from the Internet Software Consortium. Here we provide a sample configuration.

Suppose you provide a router with the following networking values:

IPv4 range:
Subnet mask:
Router IP address:
Interface connected to subnet: if0

You want to provide fixed IP addresses for two hosts: subdomain1 and subdomain2. Here is one possible method for configuring dhcpd.conf:

# cat /etc/dhcpd.conf
option domain-name "";
subnet netmask {
	option routers;
	option domain-name-servers;
#	deny unknown-clients;
	use-host-decl-names true;
	host {
		hardware ethernet e8:8b:27:7b:7a:01;
	host {
		hardware ethernet e8:8b:27:7b:7a:02;

First we set the domain name as in a dhcp option. Next, we specify our subnet starts at and has a subnet mask of

Inside our subnet declaration, we specify DHCP options. By convention, the router for a subnet is usually the first available IP address, which in our case is We run our own caching name server on this router for the subnet, so we specify the same IP address for domain-name-servers.

If we did not want to dynamically assign IP addresses to clients that we did not specifically define in dhcpd.conf, we can uncomment @@deny unknown-clients;@@. However, because we do want to assign IP addresses dynamically for some clients, we leave this commented.

By setting use-host-decl-names to true, we use the same name in the host declaration as the client hostname.

The range directive indicates the addresses that the DHCP server can assign dynamically, from to

Next, we define two hosts:

The first host is named We expect the hardware to have a MAC address of e8:8b:27:7b:7a:01 and we will assign it the fixed IP address of

The second host is named We expect the hardware to have a MAC address of e8:8b:27:7b:7a:02 and we will assign it the fixed IP address of

Now we enable, configure, and start the dhcpd server:

# rcctl enable dhcpd
# rcctl set dhcpd flags if0
# rcctl start dhcpd

Make sure to replace if0 with the actual interface your DHCP server is listening on.

Further Reading

OpenBSD recommends the book DHCP by Ted Lemon and Ralph E. Droms. Ted Lemon helped write the DHCP server used by OpenBSD.


System logs

/var/log/messages and /var/log/daemon can contain error logs like the following:

May 31 06:25:13 example dhcpd[39900]: Both dynamic and static leases present for
May 31 06:25:13 example dhcpd[39900]: Either remove host declaration or remove
May 31 06:25:13 example dhcpd[39900]: from the dynamic address pool for

In this above message, we see that a host declaration specified as a fixed address, but this IP address was also included in a range. An IP address can be present in only one or the other, but not both.


Sometimes, it can help to view packets on the wire. In this example below, I run tcpdump on the fictional if0 interface. Our machine with ethernet address e8:8b:27:7b:7a:02 is unable to get proper networking details from our router using DHCP:

# tcpdump -ne -i if0 'ether host e8:8b:27:7b:7a:02'
tcpdump: listening on if0, link-type EN10MB
11:02:06.292615 e8:8b:27:7b:7a:02 ff:ff:ff:ff:ff:ff 0800 342: >  xid:0xff7d00d5 [|bootp] [tos 0x10]
11:02:06.292622 e8:8b:27:7b:7a:02 ff:ff:ff:ff:ff:ff 0800 342: >  xid:0xff7d00d5 [|bootp] [tos 0x10]

(The lines keep repeating with the same information, so the complete dump has been truncated)

Here, tcpdump shows us that the device e8:8b:27:7b:7a:02 is sending out DHCP broadcast requests properly (labeled bootp by tcpdump), but our DHCP server is not responding. This may indicate an improperly functioning DHCP server.