How to configure a DHCP server on Rocky Linux

Estimated read time 4 min read


Jack Wallen shows you how to configure Rocky Linux 9 as a DHCP server for your local area network.

Close-up Macro Shot: Person Plugs in RJ45 Internet Connector into LAN Router Switch. Information Communication Network with Data Cable Being Connected to Port with Blinking Lights. Blue Background
Image: Gorodenkoff/Adobe Stock

Rocky Linux has become one of the de facto standard replacements for CentOS. Not only is it a drop-in replacement for RHEL, but the maintainer Gregory Kurtzer has made it clear Rocky Linux will always be available and will never be owned by a company that could bring down the distribution.

And for anyone who’s used RHEL or CentOS, Rocky Linux will be instantly familiar and can serve you and your company with ease.

SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)

Let’s take a look at one way Rocky Linux can serve you as a DHCP server. I’m going to walk you through the process of installing and configuring the DHCP server on this open source operating system. It shouldn’t take you but a few minutes to get this up and running.

What you’ll need to deploy the DHCP server

The only things you’ll need to are a running instance of Rocky Linux and a user with sudo privileges. Ready? Let’s get to work.

How to install the DHCP server software

Rocky Linux doesn’t ship with the DHCP server installed, so we’ll take care of that now. Log in to your Rocky Linux instance, open a terminal window and issue the command:

sudo dnf install dhcp-server -y

Once that’s installed, you can now move on to the configuration.

How to configure the DHCP server on Rocky Linux

Before we start to configure the DHCP server, you’ll need to know the name of the interface you’ll be using. To discover that name, issue the command:

ip a

You should at least see two listings, one for the loopback — which will use the address — and the other for your LAN-facing network device. For example, mine is enp0s3.

Next, open the DHCP server configuration file with the command:

sudo nano /etc/dhcp/dhcpd.conf

The section you need to concentrate on will look like this:

default-lease-time 900;
max-lease-time 10800;


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

You’ll want to make sure to configure this section according to your network topology. After configuring this section, save and close the file.

How to open the firewall

We now have to open the firewall for the DHCP server. First, add the rule for the firewall with:

sudo firewall-cmd --add-port=67/udp --permanent

Now, reload the firewall to apply the new rule with:

sudo firewall-cmd --reload

How to start and enable the DHCP service

With everything taken care of, you can now start and enable the service with a single command:

sudo systemctl enable --now

At this point, your Rocky Linux server is capable of serving up DHCP addresses. One thing to keep in mind, however, is that you want to make sure the configuration of this DHCP server doesn’t conflict with any other device that hands out network addresses. Such a conflict would cause problems on your LAN, so either disable any other device that would do so or configure the IP address range for the Rocky Linux DHCP server beyond that of any other device handing out addresses.

And that’s all there is to it. You now have a DHCP server up and running, served up by a powerhouse OS. Enjoy those IP addresses.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.


Source link

You May Also Like

More From Author