Basic DHCP Setup


When it comes to efficiently assigning IP addresses to multiple clients, DHCP is the de facto standard in most networks. In this post, we’ll explore DHCP configuration on Red Hat Enterprise Linux 7 and give an example of how to install it, as well as a few configuration options for dhcpd. With a basic understanding of DHCP, you can get your network up and running almost immediately.

Installing DHCP

To begin with, we’re going to walk through the installation process for DHCP. For the installation of DHCP we will use yum to download the necessary packages. Here is an example of the command,

# yum -y install dhcp

Note: For RHEL 8 the package name is dhcp-server.

Configuring DHCP

Once we’ve installed DHCP, we can now start adding settings that will make our network more secure. Edit the /etc/dhcp/dhcpd.conf by adding the statements below. This dhcpd.conf config is the one for Red Hat Enterprise Linux 7. Below are a few simple examples to get started. Add the following two sections to your configuration,

# vi /etc/dhcp/dhcpd.conf

default-lease-time 86400;
max-lease-time 172800;
option domain-name ""; option domain-name-servers; subnet netmask {
option routers;
option subnet-mask; range; } host server { hardware ethernet 00:06:5b:6e:87:4c; fixed-address; }

We have set some global parameters for lease time in seconds and the domain-name and ns server, followed by our subnet with the gateway, mask and range. Lastely, we set aside a fixed ip for a server based off the mac address. For a complete list of options, refer to the manpage, dhcpd.conf(5).

You can now start the DHCP server, but before you do, run a configuration test to verify your syntax is correct using the -t flag. This assumes the default location for the configuration file as /etc/dhcp/dhcpd.conf. If you changed to a different location, -c will need to be added to specify the new location for dhcpd.conf.

# dhcpd -t

Once you’ve loaded the configuration file, enable and start the dhcpd server.

# systemctl enable dhcpd
# systemctl start dhcpd

Open Firewall Port

By default, the bootps port 67/udp will be blocked by the Linux firewall. To permit DHCP requests to the server, open the service to the public zone with the following commands,

# firewall-cmd --zone=public --permanent --add-service=dhcp
# firewall-cmd --reload

Additional Subnets

What is a subnet declaration for DHCP and how should it be implemented? The subnet declaration is a way of making configuration more efficient. When you use subnet declaration, you are allowing DHCP to issue the IP address to a client due to its location in the network. This is beneficial because you don’t have to go into every single one of your interfaces and assign an IP address; instead, you can just choose one interface and let DHCP do the rest.

So how do we set this up? First, we’ll have to decide what address space we want our network to be in. For example, if our network address for every device is 10.10.*.* then that means that 10.10.*.0 is for the network segment and 10.10.*.255 is for the broadcast segment for a /24.

So how do we go about assigning an address to a client? Well, let’s say we have two networks defined as and, then we would define the subnet declaration as follows,

option domain-name "";

subnet netmask {
     option subnet-mask;
     option routers;

subnet netmask {
     option subnet-mask;
     option routers;

Remember, after saving changes to the dhcpd.conf, verify there are no syntax errors and restart your DHCP server

# dhcpd -t
# systemct restart dhcpd

And now you’re set.

Note: If you plan to add another router, and you want to use the same range of IPs that you had initially used, just add an additional inner declaration for that subnet.

In order to forward udp broadcast traffic from a Cisco router, simply use the ip helper-address sub-interface command to relay requests to your dhcp server. In our case, the server address is

Router> enable
Router# config t
Router(config)# interface GigabitEthernet0/0/0
Router(config-if)# ip helper-address

DHCP Logs & Lease Database

By default, DHCP sends messages to the syslog daemon facility. So, reviewing /var/log/messages may be helpful during troubleshooting. You can change this location in the dhcpd.conf file using the log-facility statement and editing rsyslog.conf if you wanted to separate these from other system logs.

It is also helpful to understand the lease database in DHCP. The lease database is a database that records an IP to a client for a period of time. The lease database is located under /var/lib/dhcpd/dhcpd.leases by default, unless otherwise specified within the dhcpd.conf file. The DHCP leases can be accessed with the following command,

# cat /var/lib/dhcpd/dhcpd.leases

Final Thoughts

In this post, we’ve installed and configured DHCP for RedHat Enterprise Linux 7. We’ve also shown you some basic examples of how to configure DHCP on your network. As you can see from this post, configuring DHCP for RedHat Enterprise Linux 7 is extremely simple and with a little planning and customization, you can ensure that your network is up and running in no time at all.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s