Setting Up DHCP Server in FreeBSD

Jul 19, 2023 • FreeBSDSoftware

This walkthrough aims to help readers get a solid grasp on how to set up a Dynamic Host Configuration Protocol (DHCP) server in FreeBSD. Implementing a DHCP server in your FreeBSD system can greatly simplify managing IP addresses of devices that are connected to your network.

This guide is designed for audiences already familiar with FreeBSD. If that’s not the case, take a quick detour to our previous Introduction to FreeBSD guide to get a basic understanding of FreeBSD’s networking environment.

Understanding DHCP

The Dynamic Host Configuration Protocol (DHCP) is a protocol that allows individual devices on an IP network to get their own network configuration information, including the IP address, subnet mask and default gateway. A DHCP server can be configured to assign and manage these configurations dynamically, alleviating the need for manual IP address configuration which can be quite challenging, especially when dealing with a large network.

Before You Start: Pre-requisites

Before proceeding, make sure you have a working installation of FreeBSD on your machine. For setting up an initial FreeBSD system, you can refer to our guide on Package Management in FreeBSD.

Step 1: Installing the DHCP Server

The easiest way to install a DHCP server in FreeBSD is through the FreeBSD ports collection. If you’re new to FreeBSD ports, you might need to familiarize yourself with the Ports system by checking out our guide on FreeBSD Ports and Packages.

To install the DHCP server, we will use the isc-dhcp43-server port. You can install it by typing the following command in the terminal:

cd /usr/ports/net/isc-dhcp43-server/ && make install clean

Step 2: Configuring the DHCP Server

The configuration file for the DHCP server is /usr/local/etc/dhcpd.conf. Before modifying this file, it’s best practice to create a backup, as covered in our post Backup and Restore FreeBSD.

Creating Subnets: First things first, we need to define the network and subnet for which the DHCP server will be assigning IP addresses. You vi can do this with the ‘subnet’ statement as follows:

subnet netmask {
    option routers;
    option domain-name-servers,;

In this example, the DHCP server will assign IP addresses between and

Specifying the Lease Time: It’s also important to specify the lease time. The lease is the length of time for which the DHCP server assigns an IP address to a client. You can do this using the ‘default-lease-time’ and ‘max-lease-time’ statements:

default-lease-time 600;
max-lease-time 7200;

Step 3: Starting the DHCP Server

Once your configuration is set up, it is time to start the DHCP service. Before starting the service, however, you should check the syntax of your configuration file by using the following command:

/usr/local/sbin/dhcpd -t -cf /usr/local/etc/dhcpd.conf

If your configuration file has no syntax errors, you can start the DHCP server by typing the following command:

service isc-dhcpd start

Additionally, to ensure that the DHCP server starts automatically at boot, you should add the following line to your /etc/rc.conf file:



Setting up a DHCP server in your FreeBSD system can greatly simplify managing IP addresses of devices that are connected to your network. It’s an essential skill for any FreeBSD user, particularly for those managing large networks. Be sure to check out our other tutorials for more ways to get the most out of your FreeBSD system. Helpful resources like Configuring Network Interfaces, Understanding Basic Commands in FreeBSD, and Common System Administration Issues can help you navigate common challenges and tasks on your FreeBSD journey.

If you encountered trouble during your setup, our Troubleshooting Guide and community forums have many knowledgeable individuals that can help you resolve your issue.

Happy networking!

Checkout these related ports: