RHEL BasedRocky Linux

How To Configure DHCP Server on Rocky Linux 9

Configure DHCP Server on Rocky Linux 9

In this tutorial, we will show you how to configure DHCP server on Rocky Linux 9. For those of you who didn’t know, a DHCP server is a network protocol that assigns an IP address and other network configurations to the devices automatically, it works by sending and receiving DHCP messages between devices and the DHCP server, DHCP server maintains a pool of IP addresses and assigns them to devices, DHCP servers can be configured to assign an IP address based on device MAC address, it also can provide additional information to devices using DHCP options.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation and configure the DHCP server on Rocky Linux. 9.

Prerequisites

  • A server running one of the following operating systems: Rocky Linux 9.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for VSCodium.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Configure DHCP Server on Rocky Linux 9

Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:

sudo dnf check-update
sudo dnf install dnf-utils

Step 2. Installing DHCP Server on Rocky Linux 9.

Run the following command in the terminal to install the DHCP server package:

sudo dnf install dhcp-server

Step 3. Configure DHCP Server on Rocky Linux 9.

After the DHCP server package is installed, we need to configure it. We will be editing the DHCP server configuration file located at /etc/dhcp/dhcpd.conf:

nano /etc/dhcp/dhcpd.conf

You can configure the DHCP server settings such as the IP address range that the DHCP server should assign, the default gateway, and the DNS server. Here is a sample configuration:

subnet 192.168.0.0 netmask 255.255.255.0 {
  range 192.168.0.100 192.168.0.200;
  option routers 192.168.0.1;
  option domain-name-servers 8.8.8.8, 8.8.4.4;
}

Save and close the file, then start the DHCP service using the following command:

sudo systemctl start dhcpd
sudo systemctl enable dhcpd

This configuration is for a subnet with IP addresses in the range of 192.168.0.0 to 192.168.0.255, with a netmask of 255.255.255.0. The DHCP server will assign IP addresses in the range of 192.168.0.100 to 192.168.0.200, the default gateway will be set to 192.168.0.1 and the DNS server will be set to 8.8.8.8 and 8.8.4.4

Step 4. Configure Firewall.

Now we configure the firewall to open the UDP port 67, start the service and make the clients connect to our server:

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

Step 5. Configure DHCP reservations.

To configure DHCP reservations, you can add a host section to the DHCP configuration file, for example:

host client1 {
  hardware ethernet 00:36:46:10:44:55;
  fixed-address 192.168.0.50;
}

This will assign the IP address 192.168.0.50 to a device with the MAC address 00:36:46:10:44:55

Step 6. Test the DHCP Server.

To test the DHCP server, you can connect a device to the network and check that it receives an IP address from the DHCP server.

Congratulations! You have successfully set up the DHCP server. Thanks for using this tutorial to configure the DHCP server on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official Rocky Linux website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button