Installing and Configuring DHCP Server (DHCPd) on FreeBSD

»»»Installing and Configuring DHCP Server (DHCPd) on FreeBSD
DHCP, the Dynamic Host Configuration Protocol, describes the means by which a system can connect to a network and obtain the necessary information for communication upon that network.

When dhclient, the DHCP client, is executed on the client machine, it begins broadcasting requests for configuration information. By default, these requests are on UDP port 68. The server replies on UDP 67, giving the client an IP address and other relevant network information such as netmask, router, and DNS servers. All of this information comes in the form of a DHCP ?lease? and is only valid for a certain time (configured by the DHCP server maintainer). In this manner, stale IP addresses for clients no longer connected to the network can be automatically reclaimed.

DHCP Server (or DHCPd) is the server that provides the DHCP client the information it needed, and it’s the server portion of the suite is not provided as part of FreeBSD, and so it needs to install from the net/isc-dhcp3-server port to provide this service.

FreeBSD comes with ISC DHCP, and it comes with FreeBSD as ports net/isc-dhcp3-server.

To install it, change to ports net/isc-dhcp3-server directory and execute the following command:

# make install clean

DHCPd is configured by using a configuration file, normally dhcpd.conf located at /usr/local/etc directory. Normally there is an example configuration file which is dhcpd.conf.example at the directory. Copy dhcpd.conf.example to dhcpd.conf or create a new dhcpd.conf before proceeding to make changes on DHCP Server.

dhcpd.conf is comprised of declarations regarding subnets and hosts, and is perhaps most easily explained using an example :

option domain-name “”; (1)
option domain-name-servers; (2)
option subnet-mask; (3)

default-lease-time 3600; (4)
max-lease-time 86400; (5)
ddns-update-style none; (6)

subnet netmask {
range; (7)
option routers; (8)

host mailhost {
hardware ethernet 02:03:04:05:06:07; (9)
fixed-address; (10)

(1) This option specifies the domain that will be provided to clients as the default search domain.
(2) This option specifies a comma separated list of DNS servers that the client should use.
(3) The netmask that will be provided to clients.
(4) A client may request a specific length of time that a lease will be valid. Otherwise the server will assign a lease with this expiry value (in seconds).
(5) This is the maximum length of time that the server will lease for. Should a client request a longer lease, a lease will be issued, although it will only be valid for max-lease-time seconds.
(6) This option specifies whether the DHCP server should attempt to update DNS when a lease is accepted or released. In the ISC implementation, this option is required.
(7) This denotes which IP addresses should be used in the pool reserved for allocating to clients. IP addresses between, and including, the ones stated are handed out to clients.
(8) Declares the default gateway that will be provided to clients.
(9) The hardware MAC address of a host (so that the DHCP server can recognize a host when it makes a request).
(10) Specifies that the host should always be given the same IP address. Note that using a hostname is correct here, since the DHCP server will resolve the hostname itself before returning the lease information.

Once you have finished writing your dhcpd.conf, you can proceed to start the server by issuing the following command:

# /usr/local/etc/rc.d/ start

Should you need to make changes to the configuration of your server in the future, it is important to note that sending a SIGHUP signal to dhcpd does not result in the configuration being reloaded, as it does with most daemons. A SIGTERM signal to stop the process, and then restart it using the command above. For example:

# ps wax | grep dhcpd

pid of dhcpd will be shown with the above command, the issue the following command to kill it.

# kill -15 (pid of dhcpd)

By | 2016-12-09T08:43:37+00:00 December 9th, 2016|Categories: Linux|Tags: , , , , |1 Comment

About the Author:

LK is a technology writer for Tech Journey with background of system and network administrator. He has be documenting his experiences in digital and technology world for over 15 years. Connect with LK through Tech Journey on Facebook, Twitter or Google+.