rss logo

Setting Up and Configuring a DHCP Server on OpenBSD

OpenBSD Logo

In this guide, I will demonstrate how to use the robust and secure OpenBSD to set up a DHCP server.

Recently I had the need to configure a DHCP server for a Wi-Fi guest network, and OpenBSD is the ideal solution for this task. It's a lightweight, highly secure, and stable choice.

Configuration

Note: For reference, there is an example file, /etc/examples/dhcpd.conf, available on the system.

  • Create and edit a /etc/dhcpd.conf file:
# $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

  • Enable the dhcpd service to run automatically at boot:
OpenBSD# rcctl enable dhcpd
  • Start the dhcpd service:
OpenBSD# rcctl start dhcpd
  • Verify the status of the dhcpd service:
OpenBSD# rcctl check dhcpd

View DHCP Leases

  • Display 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; }
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Contact :

contact mail address