Linux DHCP Installation and Configuration

This guide provides step-by-step instructions to install and configure a DHCP server on Ubuntu and Red Hat Linux.

1. Installing DHCP Server

On Ubuntu

sudo apt update
sudo apt install isc-dhcp-server

On Red Hat

sudo yum install dhcp

2. Configuring DHCP Server

Edit the DHCP configuration file to define the network settings.

On Ubuntu

sudo nano /etc/dhcp/dhcpd.conf

Add the following 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 domain-name-servers 8.8.8.8, 8.8.4.4;
}

On Red Hat

sudo nano /etc/dhcp/dhcpd.conf

Use the same configuration as above.

3. Starting and Enabling DHCP Service

On Ubuntu

sudo systemctl start isc-dhcp-server
sudo systemctl enable isc-dhcp-server

On Red Hat

sudo systemctl start dhcpd
sudo systemctl enable dhcpd

4. Verifying DHCP Server

Check the status of the DHCP server to ensure it is running:

On Ubuntu

sudo systemctl status isc-dhcp-server

On Red Hat

sudo systemctl status dhcpd

5. Logs and Troubleshooting

Check the logs for troubleshooting:

sudo tail -f /var/log/syslog  # Ubuntu
sudo tail -f /var/log/messages  # Red Hat

For more details, refer to the official documentation: