FedoraRHEL Based

How To Configure DHCP Server on Fedora 41

Configure DHCP Server on Fedora 41

Setting up and configuring a DHCP (Dynamic Host Configuration Protocol) server is a crucial skill for system administrators managing networks on Fedora Linux. DHCP automates the process of assigning IP addresses and network configuration parameters to devices on your network, eliminating the need for manual configuration. This comprehensive guide walks through the complete process of installing, configuring, and managing a DHCP server on Fedora 41.

Prerequisites

Before proceeding with the DHCP server configuration, ensure you have:

• A Fedora 41 system with root/sudo privileges
• A stable network connection
• Basic understanding of networking concepts
• At least 2GB of RAM and 20GB of storage
• SELinux configured in either permissive or enforcing mode

Step 1: Installing the DHCP Server Package

First, verify if the DHCP server package is already installed on your system:

sudo dnf list installed dhcp-server

If not installed, execute the following command to install the DHCP server package:

sudo dnf install dhcp-server

Verify the installation by checking the package version:

rpm -q dhcp-server

Step 2: Configuring the DHCP Server

The main DHCP configuration file is located at /etc/dhcp/dhcpd.conf. Create a new configuration file or edit the existing one:

sudo nano /etc/dhcp/dhcpd.conf

Add the following basic configuration:

# Global configuration options
option domain-name "example.com";
option domain-name-servers 8.8.8.8, 8.8.4.4;
default-lease-time 600;
max-lease-time 7200;
authoritative;

# Subnet configuration
subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.100 192.168.1.200;
    option routers 192.168.1.1;
    option broadcast-address 192.168.1.255;
    option subnet-mask 255.255.255.0;
}

Let’s break down these configuration parameters:

• domain-name: Specifies the domain name for your network
• domain-name-servers: DNS servers for name resolution
• default-lease-time: Duration (in seconds) for which IP addresses are leased
• max-lease-time: Maximum time a client can keep an IP address
• authoritative: Declares this DHCP server as authoritative for the network

Step 3: Configuring Firewall Rules

Configure the firewall to allow DHCP traffic:

sudo firewall-cmd --add-service=dhcp --permanent
sudo firewall-cmd --reload

Verify the firewall configuration:

sudo firewall-cmd --list-all

Step 4: Starting and Enabling the DHCP Service

Start the DHCP service and enable it to start on boot:

sudo systemctl start dhcpd
sudo systemctl enable dhcpd

Check the service status:

sudo systemctl status dhcpd

Step 5: Testing the DHCP Server Configuration

Monitor DHCP server logs in real-time:

sudo journalctl -u dhcpd -f

On a client machine, request a new IP address:

sudo dhclient -r
sudo dhclient

Verify leased IP addresses:

cat /var/lib/dhcpd/dhcpd.leases

Step 6: Advanced Configuration Options

Static IP Reservations

To assign static IP addresses to specific devices, add host declarations:

host workstation1 {
    hardware ethernet 00:11:22:33:44:55;
    fixed-address 192.168.1.50;
    option host-name "workstation1";
}

Multiple Subnet Configuration

For networks with multiple subnets:

subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.100 192.168.1.200;
    option routers 192.168.1.1;
}

subnet 10.0.0.0 netmask 255.255.255.0 {
    range 10.0.0.100 10.0.0.200;
    option routers 10.0.0.1;
}

Dynamic DNS Updates

Enable dynamic DNS updates:


ddns-update-style interim;
update-static-leases on;
key DHCP_UPDATER {
    algorithm HMAC-MD5;
    secret "your_secret_key";
}

Step 7: Securing Your DHCP Server

Interface Binding

Edit /etc/sysconfig/dhcpd to bind the DHCP server to specific interfaces:

DHCPDARGS="eth0"

Access Control

Implement allow/deny rules:

allow booting;
allow bootp;
deny unknown-clients;

Troubleshooting Common Issues

Service Fails to Start

1. Check configuration syntax:

dhcpd -t -cf /etc/dhcp/dhcpd.conf

2. Verify logs:

journalctl -xe | grep dhcpd

Clients Not Receiving IP Addresses

1. Verify network connectivity:

ping 192.168.1.1

2. Check DHCP server is listening:

sudo netstat -uap | grep dhcpd

3. Review SELinux context:

sudo semanage port -l | grep dhcpd

Best Practices

• Regularly backup your DHCP configuration file
• Monitor server logs for unusual activity
• Implement proper subnet planning
• Use meaningful lease times based on network size
• Document all static IP assignments
• Regularly update the DHCP server package

Congratulations! You have successfully set up the DHCP server. Thanks for using this tutorial to configure the DHCP server on your Fedora 41 system. For additional help or useful information, we recommend you check the official Fedora 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